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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); | 754 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); |
755 holder->set_table(*table); | 755 holder->set_table(*table); |
756 return *holder; | 756 return *holder; |
757 } | 757 } |
758 | 758 |
759 | 759 |
760 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { | 760 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { |
761 HandleScope scope(isolate); | 761 HandleScope scope(isolate); |
762 ASSERT(args.length() == 2); | 762 ASSERT(args.length() == 2); |
763 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 763 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
764 Handle<Object> key(args[1]); | 764 Handle<Object> key(args[1], isolate); |
765 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | 765 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
766 table = ObjectHashSetAdd(table, key); | 766 table = ObjectHashSetAdd(table, key); |
767 holder->set_table(*table); | 767 holder->set_table(*table); |
768 return isolate->heap()->undefined_value(); | 768 return isolate->heap()->undefined_value(); |
769 } | 769 } |
770 | 770 |
771 | 771 |
772 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { | 772 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { |
773 HandleScope scope(isolate); | 773 HandleScope scope(isolate); |
774 ASSERT(args.length() == 2); | 774 ASSERT(args.length() == 2); |
775 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 775 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
776 Handle<Object> key(args[1]); | 776 Handle<Object> key(args[1], isolate); |
777 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | 777 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
778 return isolate->heap()->ToBoolean(table->Contains(*key)); | 778 return isolate->heap()->ToBoolean(table->Contains(*key)); |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { | 782 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { |
783 HandleScope scope(isolate); | 783 HandleScope scope(isolate); |
784 ASSERT(args.length() == 2); | 784 ASSERT(args.length() == 2); |
785 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 785 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
786 Handle<Object> key(args[1]); | 786 Handle<Object> key(args[1], isolate); |
787 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | 787 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
788 table = ObjectHashSetRemove(table, key); | 788 table = ObjectHashSetRemove(table, key); |
789 holder->set_table(*table); | 789 holder->set_table(*table); |
790 return isolate->heap()->undefined_value(); | 790 return isolate->heap()->undefined_value(); |
791 } | 791 } |
792 | 792 |
793 | 793 |
794 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { | 794 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { |
795 HandleScope scope(isolate); | 795 HandleScope scope(isolate); |
796 ASSERT(args.length() == 1); | 796 ASSERT(args.length() == 1); |
(...skipping 12 matching lines...) Expand all Loading... |
809 return *holder; | 809 return *holder; |
810 } | 810 } |
811 | 811 |
812 | 812 |
813 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { | 813 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { |
814 HandleScope scope(isolate); | 814 HandleScope scope(isolate); |
815 ASSERT(args.length() == 2); | 815 ASSERT(args.length() == 2); |
816 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 816 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
817 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 817 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
818 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 818 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
819 Handle<Object> lookup(table->Lookup(*key)); | 819 Handle<Object> lookup(table->Lookup(*key), isolate); |
820 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 820 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
821 } | 821 } |
822 | 822 |
823 | 823 |
824 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { | 824 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { |
825 HandleScope scope(isolate); | 825 HandleScope scope(isolate); |
826 ASSERT(args.length() == 2); | 826 ASSERT(args.length() == 2); |
827 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 827 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
828 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 828 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
829 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 829 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
830 Handle<Object> lookup(table->Lookup(*key)); | 830 Handle<Object> lookup(table->Lookup(*key), isolate); |
831 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 831 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
832 } | 832 } |
833 | 833 |
834 | 834 |
835 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { | 835 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { |
836 HandleScope scope(isolate); | 836 HandleScope scope(isolate); |
837 ASSERT(args.length() == 2); | 837 ASSERT(args.length() == 2); |
838 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 838 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
839 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 839 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
840 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 840 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
841 Handle<Object> lookup(table->Lookup(*key)); | 841 Handle<Object> lookup(table->Lookup(*key), isolate); |
842 Handle<ObjectHashTable> new_table = | 842 Handle<ObjectHashTable> new_table = |
843 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); | 843 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
844 holder->set_table(*new_table); | 844 holder->set_table(*new_table); |
845 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 845 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
846 } | 846 } |
847 | 847 |
848 | 848 |
849 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { | 849 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { |
850 HandleScope scope(isolate); | 850 HandleScope scope(isolate); |
851 ASSERT(args.length() == 3); | 851 ASSERT(args.length() == 3); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 return WeakMapInitialize(isolate, weakmap); | 885 return WeakMapInitialize(isolate, weakmap); |
886 } | 886 } |
887 | 887 |
888 | 888 |
889 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { | 889 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { |
890 HandleScope scope(isolate); | 890 HandleScope scope(isolate); |
891 ASSERT(args.length() == 2); | 891 ASSERT(args.length() == 2); |
892 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 892 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
893 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 893 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
894 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 894 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
895 Handle<Object> lookup(table->Lookup(*key)); | 895 Handle<Object> lookup(table->Lookup(*key), isolate); |
896 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 896 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
897 } | 897 } |
898 | 898 |
899 | 899 |
900 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { | 900 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { |
901 HandleScope scope(isolate); | 901 HandleScope scope(isolate); |
902 ASSERT(args.length() == 2); | 902 ASSERT(args.length() == 2); |
903 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 903 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
904 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 904 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
905 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 905 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
906 Handle<Object> lookup(table->Lookup(*key)); | 906 Handle<Object> lookup(table->Lookup(*key), isolate); |
907 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 907 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
908 } | 908 } |
909 | 909 |
910 | 910 |
911 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { | 911 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { |
912 HandleScope scope(isolate); | 912 HandleScope scope(isolate); |
913 ASSERT(args.length() == 2); | 913 ASSERT(args.length() == 2); |
914 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 914 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
915 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 915 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
916 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 916 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
917 Handle<Object> lookup(table->Lookup(*key)); | 917 Handle<Object> lookup(table->Lookup(*key), isolate); |
918 Handle<ObjectHashTable> new_table = | 918 Handle<ObjectHashTable> new_table = |
919 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); | 919 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
920 weakmap->set_table(*new_table); | 920 weakmap->set_table(*new_table); |
921 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 921 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
922 } | 922 } |
923 | 923 |
924 | 924 |
925 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { | 925 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { |
926 HandleScope scope(isolate); | 926 HandleScope scope(isolate); |
927 ASSERT(args.length() == 3); | 927 ASSERT(args.length() == 3); |
928 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 928 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
929 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 929 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
930 Handle<Object> value(args[2]); | 930 Handle<Object> value(args[2], isolate); |
931 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 931 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
932 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | 932 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
933 weakmap->set_table(*new_table); | 933 weakmap->set_table(*new_table); |
934 return isolate->heap()->undefined_value(); | 934 return isolate->heap()->undefined_value(); |
935 } | 935 } |
936 | 936 |
937 | 937 |
938 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 938 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
939 NoHandleAllocation ha; | 939 NoHandleAllocation ha(isolate); |
940 ASSERT(args.length() == 1); | 940 ASSERT(args.length() == 1); |
941 Object* obj = args[0]; | 941 Object* obj = args[0]; |
942 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 942 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
943 return JSObject::cast(obj)->class_name(); | 943 return JSObject::cast(obj)->class_name(); |
944 } | 944 } |
945 | 945 |
946 | 946 |
947 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 947 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
948 NoHandleAllocation ha; | 948 NoHandleAllocation ha(isolate); |
949 ASSERT(args.length() == 1); | 949 ASSERT(args.length() == 1); |
950 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0); | 950 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0); |
951 Object* obj = input_obj; | 951 Object* obj = input_obj; |
952 // We don't expect access checks to be needed on JSProxy objects. | 952 // We don't expect access checks to be needed on JSProxy objects. |
953 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 953 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
954 do { | 954 do { |
955 if (obj->IsAccessCheckNeeded() && | 955 if (obj->IsAccessCheckNeeded() && |
956 !isolate->MayNamedAccess(JSObject::cast(obj), | 956 !isolate->MayNamedAccess(JSObject::cast(obj), |
957 isolate->heap()->Proto_symbol(), | 957 isolate->heap()->Proto_symbol(), |
958 v8::ACCESS_GET)) { | 958 v8::ACCESS_GET)) { |
959 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); | 959 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); |
960 return isolate->heap()->undefined_value(); | 960 return isolate->heap()->undefined_value(); |
961 } | 961 } |
962 obj = obj->GetPrototype(); | 962 obj = obj->GetPrototype(); |
963 } while (obj->IsJSObject() && | 963 } while (obj->IsJSObject() && |
964 JSObject::cast(obj)->map()->is_hidden_prototype()); | 964 JSObject::cast(obj)->map()->is_hidden_prototype()); |
965 return obj; | 965 return obj; |
966 } | 966 } |
967 | 967 |
968 | 968 |
969 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 969 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
970 NoHandleAllocation ha; | 970 NoHandleAllocation ha(isolate); |
971 ASSERT(args.length() == 2); | 971 ASSERT(args.length() == 2); |
972 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 972 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
973 Object* O = args[0]; | 973 Object* O = args[0]; |
974 Object* V = args[1]; | 974 Object* V = args[1]; |
975 while (true) { | 975 while (true) { |
976 Object* prototype = V->GetPrototype(); | 976 Object* prototype = V->GetPrototype(); |
977 if (prototype->IsNull()) return isolate->heap()->false_value(); | 977 if (prototype->IsNull()) return isolate->heap()->false_value(); |
978 if (O == prototype) return isolate->heap()->true_value(); | 978 if (O == prototype) return isolate->heap()->true_value(); |
979 V = prototype; | 979 V = prototype; |
980 } | 980 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 Handle<AccessorPair> accessors(raw_accessors, isolate); | 1116 Handle<AccessorPair> accessors(raw_accessors, isolate); |
1117 | 1117 |
1118 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 1118 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
1119 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 1119 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
1120 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 1120 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
1121 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); | 1121 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); |
1122 | 1122 |
1123 if (raw_accessors == NULL) { | 1123 if (raw_accessors == NULL) { |
1124 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 1124 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
1125 // GetProperty does access check. | 1125 // GetProperty does access check. |
1126 Handle<Object> value = GetProperty(obj, name); | 1126 Handle<Object> value = GetProperty(isolate, obj, name); |
1127 if (value.is_null()) return Failure::Exception(); | 1127 if (value.is_null()) return Failure::Exception(); |
1128 elms->set(VALUE_INDEX, *value); | 1128 elms->set(VALUE_INDEX, *value); |
1129 } else { | 1129 } else { |
1130 // Access checks are performed for both accessors separately. | 1130 // Access checks are performed for both accessors separately. |
1131 // When they fail, the respective field is not set in the descriptor. | 1131 // When they fail, the respective field is not set in the descriptor. |
1132 Object* getter = accessors->GetComponent(ACCESSOR_GETTER); | 1132 Object* getter = accessors->GetComponent(ACCESSOR_GETTER); |
1133 Object* setter = accessors->GetComponent(ACCESSOR_SETTER); | 1133 Object* setter = accessors->GetComponent(ACCESSOR_SETTER); |
1134 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) { | 1134 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) { |
1135 elms->set(GETTER_INDEX, getter); | 1135 elms->set(GETTER_INDEX, getter); |
1136 } | 1136 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 RETURN_IF_EMPTY_HANDLE(isolate, | 1470 RETURN_IF_EMPTY_HANDLE(isolate, |
1471 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); | 1471 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); |
1472 } | 1472 } |
1473 } | 1473 } |
1474 | 1474 |
1475 return isolate->heap()->undefined_value(); | 1475 return isolate->heap()->undefined_value(); |
1476 } | 1476 } |
1477 | 1477 |
1478 | 1478 |
1479 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 1479 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
1480 NoHandleAllocation nha; | 1480 NoHandleAllocation nha(isolate); |
1481 // args[0] == name | 1481 // args[0] == name |
1482 // args[1] == language_mode | 1482 // args[1] == language_mode |
1483 // args[2] == value (optional) | 1483 // args[2] == value (optional) |
1484 | 1484 |
1485 // Determine if we need to assign to the variable if it already | 1485 // Determine if we need to assign to the variable if it already |
1486 // exists (based on the number of arguments). | 1486 // exists (based on the number of arguments). |
1487 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 1487 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
1488 bool assign = args.length() == 3; | 1488 bool assign = args.length() == 3; |
1489 | 1489 |
1490 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 1490 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 if (has_pending_exception) { | 1943 if (has_pending_exception) { |
1944 ASSERT(isolate->has_pending_exception()); | 1944 ASSERT(isolate->has_pending_exception()); |
1945 return Failure::Exception(); | 1945 return Failure::Exception(); |
1946 } | 1946 } |
1947 literals->set(index, *regexp); | 1947 literals->set(index, *regexp); |
1948 return *regexp; | 1948 return *regexp; |
1949 } | 1949 } |
1950 | 1950 |
1951 | 1951 |
1952 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { | 1952 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { |
1953 NoHandleAllocation ha; | 1953 NoHandleAllocation ha(isolate); |
1954 ASSERT(args.length() == 1); | 1954 ASSERT(args.length() == 1); |
1955 | 1955 |
1956 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1956 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
1957 return f->shared()->name(); | 1957 return f->shared()->name(); |
1958 } | 1958 } |
1959 | 1959 |
1960 | 1960 |
1961 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { | 1961 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { |
1962 NoHandleAllocation ha; | 1962 NoHandleAllocation ha(isolate); |
1963 ASSERT(args.length() == 2); | 1963 ASSERT(args.length() == 2); |
1964 | 1964 |
1965 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1965 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
1966 CONVERT_ARG_CHECKED(String, name, 1); | 1966 CONVERT_ARG_CHECKED(String, name, 1); |
1967 f->shared()->set_name(name); | 1967 f->shared()->set_name(name); |
1968 return isolate->heap()->undefined_value(); | 1968 return isolate->heap()->undefined_value(); |
1969 } | 1969 } |
1970 | 1970 |
1971 | 1971 |
1972 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { | 1972 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
1973 NoHandleAllocation ha; | 1973 NoHandleAllocation ha(isolate); |
1974 ASSERT(args.length() == 1); | 1974 ASSERT(args.length() == 1); |
1975 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1975 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
1976 return isolate->heap()->ToBoolean( | 1976 return isolate->heap()->ToBoolean( |
1977 f->shared()->name_should_print_as_anonymous()); | 1977 f->shared()->name_should_print_as_anonymous()); |
1978 } | 1978 } |
1979 | 1979 |
1980 | 1980 |
1981 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 1981 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
1982 NoHandleAllocation ha; | 1982 NoHandleAllocation ha(isolate); |
1983 ASSERT(args.length() == 1); | 1983 ASSERT(args.length() == 1); |
1984 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1984 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
1985 f->shared()->set_name_should_print_as_anonymous(true); | 1985 f->shared()->set_name_should_print_as_anonymous(true); |
1986 return isolate->heap()->undefined_value(); | 1986 return isolate->heap()->undefined_value(); |
1987 } | 1987 } |
1988 | 1988 |
1989 | 1989 |
1990 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 1990 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
1991 NoHandleAllocation ha; | 1991 NoHandleAllocation ha(isolate); |
1992 ASSERT(args.length() == 1); | 1992 ASSERT(args.length() == 1); |
1993 | 1993 |
1994 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1994 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
1995 f->RemovePrototype(); | 1995 f->RemovePrototype(); |
1996 | 1996 |
1997 return isolate->heap()->undefined_value(); | 1997 return isolate->heap()->undefined_value(); |
1998 } | 1998 } |
1999 | 1999 |
2000 | 2000 |
2001 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { | 2001 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { |
(...skipping 12 matching lines...) Expand all Loading... |
2014 HandleScope scope(isolate); | 2014 HandleScope scope(isolate); |
2015 ASSERT(args.length() == 1); | 2015 ASSERT(args.length() == 1); |
2016 | 2016 |
2017 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 2017 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
2018 Handle<SharedFunctionInfo> shared(f->shared()); | 2018 Handle<SharedFunctionInfo> shared(f->shared()); |
2019 return *shared->GetSourceCode(); | 2019 return *shared->GetSourceCode(); |
2020 } | 2020 } |
2021 | 2021 |
2022 | 2022 |
2023 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { | 2023 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { |
2024 NoHandleAllocation ha; | 2024 NoHandleAllocation ha(isolate); |
2025 ASSERT(args.length() == 1); | 2025 ASSERT(args.length() == 1); |
2026 | 2026 |
2027 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2027 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2028 int pos = fun->shared()->start_position(); | 2028 int pos = fun->shared()->start_position(); |
2029 return Smi::FromInt(pos); | 2029 return Smi::FromInt(pos); |
2030 } | 2030 } |
2031 | 2031 |
2032 | 2032 |
2033 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { | 2033 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { |
2034 ASSERT(args.length() == 2); | 2034 ASSERT(args.length() == 2); |
2035 | 2035 |
2036 CONVERT_ARG_CHECKED(Code, code, 0); | 2036 CONVERT_ARG_CHECKED(Code, code, 0); |
2037 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2037 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
2038 | 2038 |
2039 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2039 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
2040 | 2040 |
2041 Address pc = code->address() + offset; | 2041 Address pc = code->address() + offset; |
2042 return Smi::FromInt(code->SourcePosition(pc)); | 2042 return Smi::FromInt(code->SourcePosition(pc)); |
2043 } | 2043 } |
2044 | 2044 |
2045 | 2045 |
2046 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { | 2046 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { |
2047 NoHandleAllocation ha; | 2047 NoHandleAllocation ha(isolate); |
2048 ASSERT(args.length() == 2); | 2048 ASSERT(args.length() == 2); |
2049 | 2049 |
2050 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2050 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2051 CONVERT_ARG_CHECKED(String, name, 1); | 2051 CONVERT_ARG_CHECKED(String, name, 1); |
2052 fun->SetInstanceClassName(name); | 2052 fun->SetInstanceClassName(name); |
2053 return isolate->heap()->undefined_value(); | 2053 return isolate->heap()->undefined_value(); |
2054 } | 2054 } |
2055 | 2055 |
2056 | 2056 |
2057 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { | 2057 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { |
2058 NoHandleAllocation ha; | 2058 NoHandleAllocation ha(isolate); |
2059 ASSERT(args.length() == 2); | 2059 ASSERT(args.length() == 2); |
2060 | 2060 |
2061 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2061 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2062 CONVERT_SMI_ARG_CHECKED(length, 1); | 2062 CONVERT_SMI_ARG_CHECKED(length, 1); |
2063 fun->shared()->set_length(length); | 2063 fun->shared()->set_length(length); |
2064 return isolate->heap()->undefined_value(); | 2064 return isolate->heap()->undefined_value(); |
2065 } | 2065 } |
2066 | 2066 |
2067 | 2067 |
2068 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 2068 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { |
2069 NoHandleAllocation ha; | 2069 NoHandleAllocation ha(isolate); |
2070 ASSERT(args.length() == 2); | 2070 ASSERT(args.length() == 2); |
2071 | 2071 |
2072 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2072 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2073 ASSERT(fun->should_have_prototype()); | 2073 ASSERT(fun->should_have_prototype()); |
2074 Object* obj; | 2074 Object* obj; |
2075 { MaybeObject* maybe_obj = | 2075 { MaybeObject* maybe_obj = |
2076 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 2076 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
2077 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2077 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2078 } | 2078 } |
2079 return args[0]; // return TOS | 2079 return args[0]; // return TOS |
2080 } | 2080 } |
2081 | 2081 |
2082 | 2082 |
2083 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2083 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
2084 NoHandleAllocation ha; | 2084 NoHandleAllocation ha(isolate); |
2085 RUNTIME_ASSERT(args.length() == 1); | 2085 RUNTIME_ASSERT(args.length() == 1); |
2086 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 2086 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
2087 | 2087 |
2088 String* name = isolate->heap()->prototype_symbol(); | 2088 String* name = isolate->heap()->prototype_symbol(); |
2089 | 2089 |
2090 if (function->HasFastProperties()) { | 2090 if (function->HasFastProperties()) { |
2091 // Construct a new field descriptor with updated attributes. | 2091 // Construct a new field descriptor with updated attributes. |
2092 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2092 DescriptorArray* instance_desc = function->map()->instance_descriptors(); |
2093 | 2093 |
2094 int index = instance_desc->SearchWithCache(name, function->map()); | 2094 int index = instance_desc->SearchWithCache(name, function->map()); |
(...skipping 22 matching lines...) Expand all Loading... |
2117 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2117 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
2118 details.type(), | 2118 details.type(), |
2119 details.dictionary_index()); | 2119 details.dictionary_index()); |
2120 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2120 function->property_dictionary()->DetailsAtPut(entry, new_details); |
2121 } | 2121 } |
2122 return function; | 2122 return function; |
2123 } | 2123 } |
2124 | 2124 |
2125 | 2125 |
2126 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2126 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
2127 NoHandleAllocation ha; | 2127 NoHandleAllocation ha(isolate); |
2128 ASSERT(args.length() == 1); | 2128 ASSERT(args.length() == 1); |
2129 | 2129 |
2130 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2130 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2131 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 2131 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
2132 } | 2132 } |
2133 | 2133 |
2134 | 2134 |
2135 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 2135 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
2136 NoHandleAllocation ha; | 2136 NoHandleAllocation ha(isolate); |
2137 ASSERT(args.length() == 1); | 2137 ASSERT(args.length() == 1); |
2138 | 2138 |
2139 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2139 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2140 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 2140 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
2141 } | 2141 } |
2142 | 2142 |
2143 | 2143 |
2144 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 2144 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
2145 HandleScope scope(isolate); | 2145 HandleScope scope(isolate); |
2146 ASSERT(args.length() == 2); | 2146 ASSERT(args.length() == 2); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 if (char_code->ToArrayIndex(&code)) { | 2221 if (char_code->ToArrayIndex(&code)) { |
2222 if (code <= 0xffff) { | 2222 if (code <= 0xffff) { |
2223 return isolate->heap()->LookupSingleCharacterStringFromCode(code); | 2223 return isolate->heap()->LookupSingleCharacterStringFromCode(code); |
2224 } | 2224 } |
2225 } | 2225 } |
2226 return isolate->heap()->empty_string(); | 2226 return isolate->heap()->empty_string(); |
2227 } | 2227 } |
2228 | 2228 |
2229 | 2229 |
2230 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { | 2230 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { |
2231 NoHandleAllocation ha; | 2231 NoHandleAllocation ha(isolate); |
2232 ASSERT(args.length() == 2); | 2232 ASSERT(args.length() == 2); |
2233 | 2233 |
2234 CONVERT_ARG_CHECKED(String, subject, 0); | 2234 CONVERT_ARG_CHECKED(String, subject, 0); |
2235 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 2235 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
2236 | 2236 |
2237 // Flatten the string. If someone wants to get a char at an index | 2237 // Flatten the string. If someone wants to get a char at an index |
2238 // in a cons string, it is likely that more indices will be | 2238 // in a cons string, it is likely that more indices will be |
2239 // accessed. | 2239 // accessed. |
2240 Object* flat; | 2240 Object* flat; |
2241 { MaybeObject* maybe_flat = subject->TryFlatten(); | 2241 { MaybeObject* maybe_flat = subject->TryFlatten(); |
2242 if (!maybe_flat->ToObject(&flat)) return maybe_flat; | 2242 if (!maybe_flat->ToObject(&flat)) return maybe_flat; |
2243 } | 2243 } |
2244 subject = String::cast(flat); | 2244 subject = String::cast(flat); |
2245 | 2245 |
2246 if (i >= static_cast<uint32_t>(subject->length())) { | 2246 if (i >= static_cast<uint32_t>(subject->length())) { |
2247 return isolate->heap()->nan_value(); | 2247 return isolate->heap()->nan_value(); |
2248 } | 2248 } |
2249 | 2249 |
2250 return Smi::FromInt(subject->Get(i)); | 2250 return Smi::FromInt(subject->Get(i)); |
2251 } | 2251 } |
2252 | 2252 |
2253 | 2253 |
2254 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { | 2254 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { |
2255 NoHandleAllocation ha; | 2255 NoHandleAllocation ha(isolate); |
2256 ASSERT(args.length() == 1); | 2256 ASSERT(args.length() == 1); |
2257 return CharFromCode(isolate, args[0]); | 2257 return CharFromCode(isolate, args[0]); |
2258 } | 2258 } |
2259 | 2259 |
2260 | 2260 |
2261 class FixedArrayBuilder { | 2261 class FixedArrayBuilder { |
2262 public: | 2262 public: |
2263 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) | 2263 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) |
2264 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), | 2264 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), |
2265 length_(0), | 2265 length_(0), |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3471 pat_vector, | 3471 pat_vector, |
3472 start_index); | 3472 start_index); |
3473 } | 3473 } |
3474 } | 3474 } |
3475 | 3475 |
3476 return Smi::FromInt(position); | 3476 return Smi::FromInt(position); |
3477 } | 3477 } |
3478 | 3478 |
3479 | 3479 |
3480 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { | 3480 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { |
3481 NoHandleAllocation ha; | 3481 NoHandleAllocation ha(isolate); |
3482 ASSERT(args.length() == 2); | 3482 ASSERT(args.length() == 2); |
3483 | 3483 |
3484 CONVERT_ARG_CHECKED(String, str1, 0); | 3484 CONVERT_ARG_CHECKED(String, str1, 0); |
3485 CONVERT_ARG_CHECKED(String, str2, 1); | 3485 CONVERT_ARG_CHECKED(String, str2, 1); |
3486 | 3486 |
3487 if (str1 == str2) return Smi::FromInt(0); // Equal. | 3487 if (str1 == str2) return Smi::FromInt(0); // Equal. |
3488 int str1_length = str1->length(); | 3488 int str1_length = str1->length(); |
3489 int str2_length = str2->length(); | 3489 int str2_length = str2->length(); |
3490 | 3490 |
3491 // Decide trivial cases without flattening. | 3491 // Decide trivial cases without flattening. |
(...skipping 27 matching lines...) Expand all Loading... |
3519 uint16_t char1 = stream1.GetNext(); | 3519 uint16_t char1 = stream1.GetNext(); |
3520 uint16_t char2 = stream2.GetNext(); | 3520 uint16_t char2 = stream2.GetNext(); |
3521 if (char1 != char2) return Smi::FromInt(char1 - char2); | 3521 if (char1 != char2) return Smi::FromInt(char1 - char2); |
3522 } | 3522 } |
3523 | 3523 |
3524 return Smi::FromInt(str1_length - str2_length); | 3524 return Smi::FromInt(str1_length - str2_length); |
3525 } | 3525 } |
3526 | 3526 |
3527 | 3527 |
3528 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { | 3528 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { |
3529 NoHandleAllocation ha; | 3529 NoHandleAllocation ha(isolate); |
3530 ASSERT(args.length() == 3); | 3530 ASSERT(args.length() == 3); |
3531 | 3531 |
3532 CONVERT_ARG_CHECKED(String, value, 0); | 3532 CONVERT_ARG_CHECKED(String, value, 0); |
3533 int start, end; | 3533 int start, end; |
3534 // We have a fast integer-only case here to avoid a conversion to double in | 3534 // We have a fast integer-only case here to avoid a conversion to double in |
3535 // the common case where from and to are Smis. | 3535 // the common case where from and to are Smis. |
3536 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 3536 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
3537 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 3537 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
3538 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 3538 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
3539 start = from_number; | 3539 start = from_number; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3626 int capture_count = regexp->CaptureCount(); | 3626 int capture_count = regexp->CaptureCount(); |
3627 int subject_length = subject->length(); | 3627 int subject_length = subject->length(); |
3628 | 3628 |
3629 static const int kMinLengthToCache = 0x1000; | 3629 static const int kMinLengthToCache = 0x1000; |
3630 | 3630 |
3631 if (subject_length > kMinLengthToCache) { | 3631 if (subject_length > kMinLengthToCache) { |
3632 Handle<Object> cached_answer(RegExpResultsCache::Lookup( | 3632 Handle<Object> cached_answer(RegExpResultsCache::Lookup( |
3633 isolate->heap(), | 3633 isolate->heap(), |
3634 *subject, | 3634 *subject, |
3635 regexp->data(), | 3635 regexp->data(), |
3636 RegExpResultsCache::REGEXP_MULTIPLE_INDICES)); | 3636 RegExpResultsCache::REGEXP_MULTIPLE_INDICES), isolate); |
3637 if (*cached_answer != Smi::FromInt(0)) { | 3637 if (*cached_answer != Smi::FromInt(0)) { |
3638 Handle<FixedArray> cached_fixed_array = | 3638 Handle<FixedArray> cached_fixed_array = |
3639 Handle<FixedArray>(FixedArray::cast(*cached_answer)); | 3639 Handle<FixedArray>(FixedArray::cast(*cached_answer)); |
3640 // The cache FixedArray is a COW-array and can therefore be reused. | 3640 // The cache FixedArray is a COW-array and can therefore be reused. |
3641 isolate->factory()->SetContent(result_array, cached_fixed_array); | 3641 isolate->factory()->SetContent(result_array, cached_fixed_array); |
3642 // The actual length of the result array is stored in the last element of | 3642 // The actual length of the result array is stored in the last element of |
3643 // the backing store (the backing FixedArray may have a larger capacity). | 3643 // the backing store (the backing FixedArray may have a larger capacity). |
3644 Object* cached_fixed_array_last_element = | 3644 Object* cached_fixed_array_last_element = |
3645 cached_fixed_array->get(cached_fixed_array->length() - 1); | 3645 cached_fixed_array->get(cached_fixed_array->length() - 1); |
3646 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); | 3646 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3782 return SearchRegExpMultiple<false>( | 3782 return SearchRegExpMultiple<false>( |
3783 isolate, subject, regexp, last_match_info, result_array); | 3783 isolate, subject, regexp, last_match_info, result_array); |
3784 } else { | 3784 } else { |
3785 return SearchRegExpMultiple<true>( | 3785 return SearchRegExpMultiple<true>( |
3786 isolate, subject, regexp, last_match_info, result_array); | 3786 isolate, subject, regexp, last_match_info, result_array); |
3787 } | 3787 } |
3788 } | 3788 } |
3789 | 3789 |
3790 | 3790 |
3791 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { | 3791 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { |
3792 NoHandleAllocation ha; | 3792 NoHandleAllocation ha(isolate); |
3793 ASSERT(args.length() == 2); | 3793 ASSERT(args.length() == 2); |
3794 CONVERT_SMI_ARG_CHECKED(radix, 1); | 3794 CONVERT_SMI_ARG_CHECKED(radix, 1); |
3795 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 3795 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
3796 | 3796 |
3797 // Fast case where the result is a one character string. | 3797 // Fast case where the result is a one character string. |
3798 if (args[0]->IsSmi()) { | 3798 if (args[0]->IsSmi()) { |
3799 int value = args.smi_at(0); | 3799 int value = args.smi_at(0); |
3800 if (value >= 0 && value < radix) { | 3800 if (value >= 0 && value < radix) { |
3801 // Character array used for conversion. | 3801 // Character array used for conversion. |
3802 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; | 3802 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; |
(...skipping 15 matching lines...) Expand all Loading... |
3818 } | 3818 } |
3819 char* str = DoubleToRadixCString(value, radix); | 3819 char* str = DoubleToRadixCString(value, radix); |
3820 MaybeObject* result = | 3820 MaybeObject* result = |
3821 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3821 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
3822 DeleteArray(str); | 3822 DeleteArray(str); |
3823 return result; | 3823 return result; |
3824 } | 3824 } |
3825 | 3825 |
3826 | 3826 |
3827 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 3827 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { |
3828 NoHandleAllocation ha; | 3828 NoHandleAllocation ha(isolate); |
3829 ASSERT(args.length() == 2); | 3829 ASSERT(args.length() == 2); |
3830 | 3830 |
3831 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 3831 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
3832 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 3832 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
3833 int f = FastD2IChecked(f_number); | 3833 int f = FastD2IChecked(f_number); |
3834 RUNTIME_ASSERT(f >= 0); | 3834 RUNTIME_ASSERT(f >= 0); |
3835 char* str = DoubleToFixedCString(value, f); | 3835 char* str = DoubleToFixedCString(value, f); |
3836 MaybeObject* res = | 3836 MaybeObject* res = |
3837 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3837 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
3838 DeleteArray(str); | 3838 DeleteArray(str); |
3839 return res; | 3839 return res; |
3840 } | 3840 } |
3841 | 3841 |
3842 | 3842 |
3843 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 3843 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
3844 NoHandleAllocation ha; | 3844 NoHandleAllocation ha(isolate); |
3845 ASSERT(args.length() == 2); | 3845 ASSERT(args.length() == 2); |
3846 | 3846 |
3847 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 3847 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
3848 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 3848 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
3849 int f = FastD2IChecked(f_number); | 3849 int f = FastD2IChecked(f_number); |
3850 RUNTIME_ASSERT(f >= -1 && f <= 20); | 3850 RUNTIME_ASSERT(f >= -1 && f <= 20); |
3851 char* str = DoubleToExponentialCString(value, f); | 3851 char* str = DoubleToExponentialCString(value, f); |
3852 MaybeObject* res = | 3852 MaybeObject* res = |
3853 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3853 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
3854 DeleteArray(str); | 3854 DeleteArray(str); |
3855 return res; | 3855 return res; |
3856 } | 3856 } |
3857 | 3857 |
3858 | 3858 |
3859 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 3859 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
3860 NoHandleAllocation ha; | 3860 NoHandleAllocation ha(isolate); |
3861 ASSERT(args.length() == 2); | 3861 ASSERT(args.length() == 2); |
3862 | 3862 |
3863 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 3863 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
3864 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 3864 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
3865 int f = FastD2IChecked(f_number); | 3865 int f = FastD2IChecked(f_number); |
3866 RUNTIME_ASSERT(f >= 1 && f <= 21); | 3866 RUNTIME_ASSERT(f >= 1 && f <= 21); |
3867 char* str = DoubleToPrecisionCString(value, f); | 3867 char* str = DoubleToPrecisionCString(value, f); |
3868 MaybeObject* res = | 3868 MaybeObject* res = |
3869 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3869 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
3870 DeleteArray(str); | 3870 DeleteArray(str); |
3871 return res; | 3871 return res; |
3872 } | 3872 } |
3873 | 3873 |
3874 | 3874 |
3875 // Returns a single character string where first character equals | 3875 // Returns a single character string where first character equals |
3876 // string->Get(index). | 3876 // string->Get(index). |
3877 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { | 3877 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { |
3878 if (index < static_cast<uint32_t>(string->length())) { | 3878 if (index < static_cast<uint32_t>(string->length())) { |
3879 string->TryFlatten(); | 3879 string->TryFlatten(); |
3880 return LookupSingleCharacterStringFromCode( | 3880 return LookupSingleCharacterStringFromCode( |
| 3881 string->GetIsolate(), |
3881 string->Get(index)); | 3882 string->Get(index)); |
3882 } | 3883 } |
3883 return Execution::CharAt(string, index); | 3884 return Execution::CharAt(string, index); |
3884 } | 3885 } |
3885 | 3886 |
3886 | 3887 |
3887 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate, | 3888 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate, |
3888 Handle<Object> object, | 3889 Handle<Object> object, |
3889 uint32_t index) { | 3890 uint32_t index) { |
3890 // Handle [] indexing on Strings | 3891 // Handle [] indexing on Strings |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3944 // the element if so. | 3945 // the element if so. |
3945 if (name->AsArrayIndex(&index)) { | 3946 if (name->AsArrayIndex(&index)) { |
3946 return GetElementOrCharAt(isolate, object, index); | 3947 return GetElementOrCharAt(isolate, object, index); |
3947 } else { | 3948 } else { |
3948 return object->GetProperty(*name); | 3949 return object->GetProperty(*name); |
3949 } | 3950 } |
3950 } | 3951 } |
3951 | 3952 |
3952 | 3953 |
3953 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 3954 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
3954 NoHandleAllocation ha; | 3955 NoHandleAllocation ha(isolate); |
3955 ASSERT(args.length() == 2); | 3956 ASSERT(args.length() == 2); |
3956 | 3957 |
3957 Handle<Object> object = args.at<Object>(0); | 3958 Handle<Object> object = args.at<Object>(0); |
3958 Handle<Object> key = args.at<Object>(1); | 3959 Handle<Object> key = args.at<Object>(1); |
3959 | 3960 |
3960 return Runtime::GetObjectProperty(isolate, object, key); | 3961 return Runtime::GetObjectProperty(isolate, object, key); |
3961 } | 3962 } |
3962 | 3963 |
3963 | 3964 |
3964 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. | 3965 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. |
3965 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 3966 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
3966 NoHandleAllocation ha; | 3967 NoHandleAllocation ha(isolate); |
3967 ASSERT(args.length() == 2); | 3968 ASSERT(args.length() == 2); |
3968 | 3969 |
3969 // Fast cases for getting named properties of the receiver JSObject | 3970 // Fast cases for getting named properties of the receiver JSObject |
3970 // itself. | 3971 // itself. |
3971 // | 3972 // |
3972 // The global proxy objects has to be excluded since LocalLookup on | 3973 // The global proxy objects has to be excluded since LocalLookup on |
3973 // the global proxy object can return a valid result even though the | 3974 // the global proxy object can return a valid result even though the |
3974 // global proxy object never has properties. This is the case | 3975 // global proxy object never has properties. This is the case |
3975 // because the global proxy object forwards everything to its hidden | 3976 // because the global proxy object forwards everything to its hidden |
3976 // prototype including local lookups. | 3977 // prototype including local lookups. |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4357 if (has_pending_exception) return Failure::Exception(); | 4358 if (has_pending_exception) return Failure::Exception(); |
4358 key_string = Handle<String>::cast(converted); | 4359 key_string = Handle<String>::cast(converted); |
4359 } | 4360 } |
4360 | 4361 |
4361 key_string->TryFlatten(); | 4362 key_string->TryFlatten(); |
4362 return receiver->DeleteProperty(*key_string, JSReceiver::FORCE_DELETION); | 4363 return receiver->DeleteProperty(*key_string, JSReceiver::FORCE_DELETION); |
4363 } | 4364 } |
4364 | 4365 |
4365 | 4366 |
4366 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 4367 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
4367 NoHandleAllocation ha; | 4368 NoHandleAllocation ha(isolate); |
4368 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 4369 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
4369 | 4370 |
4370 Handle<Object> object = args.at<Object>(0); | 4371 Handle<Object> object = args.at<Object>(0); |
4371 Handle<Object> key = args.at<Object>(1); | 4372 Handle<Object> key = args.at<Object>(1); |
4372 Handle<Object> value = args.at<Object>(2); | 4373 Handle<Object> value = args.at<Object>(2); |
4373 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 4374 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
4374 RUNTIME_ASSERT( | 4375 RUNTIME_ASSERT( |
4375 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4376 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4376 // Compute attributes. | 4377 // Compute attributes. |
4377 PropertyAttributes attributes = | 4378 PropertyAttributes attributes = |
(...skipping 18 matching lines...) Expand all Loading... |
4396 HandleScope scope(isolate); | 4397 HandleScope scope(isolate); |
4397 RUNTIME_ASSERT(args.length() == 2); | 4398 RUNTIME_ASSERT(args.length() == 2); |
4398 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 4399 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
4399 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 4400 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
4400 JSObject::TransitionElementsKind(array, map->elements_kind()); | 4401 JSObject::TransitionElementsKind(array, map->elements_kind()); |
4401 return *array; | 4402 return *array; |
4402 } | 4403 } |
4403 | 4404 |
4404 | 4405 |
4405 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { | 4406 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { |
4406 NoHandleAllocation ha; | 4407 NoHandleAllocation ha(isolate); |
4407 RUNTIME_ASSERT(args.length() == 1); | 4408 RUNTIME_ASSERT(args.length() == 1); |
4408 Handle<Object> object = args.at<Object>(0); | 4409 Handle<Object> object = args.at<Object>(0); |
4409 if (object->IsJSObject()) { | 4410 if (object->IsJSObject()) { |
4410 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | 4411 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); |
4411 ASSERT(!js_object->map()->is_observed()); | 4412 ASSERT(!js_object->map()->is_observed()); |
4412 ElementsKind new_kind = js_object->HasFastHoleyElements() | 4413 ElementsKind new_kind = js_object->HasFastHoleyElements() |
4413 ? FAST_HOLEY_DOUBLE_ELEMENTS | 4414 ? FAST_HOLEY_DOUBLE_ELEMENTS |
4414 : FAST_DOUBLE_ELEMENTS; | 4415 : FAST_DOUBLE_ELEMENTS; |
4415 return TransitionElements(object, new_kind, isolate); | 4416 return TransitionElements(object, new_kind, isolate); |
4416 } else { | 4417 } else { |
4417 return *object; | 4418 return *object; |
4418 } | 4419 } |
4419 } | 4420 } |
4420 | 4421 |
4421 | 4422 |
4422 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { | 4423 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { |
4423 NoHandleAllocation ha; | 4424 NoHandleAllocation ha(isolate); |
4424 RUNTIME_ASSERT(args.length() == 1); | 4425 RUNTIME_ASSERT(args.length() == 1); |
4425 Handle<Object> object = args.at<Object>(0); | 4426 Handle<Object> object = args.at<Object>(0); |
4426 if (object->IsJSObject()) { | 4427 if (object->IsJSObject()) { |
4427 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | 4428 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); |
4428 ASSERT(!js_object->map()->is_observed()); | 4429 ASSERT(!js_object->map()->is_observed()); |
4429 ElementsKind new_kind = js_object->HasFastHoleyElements() | 4430 ElementsKind new_kind = js_object->HasFastHoleyElements() |
4430 ? FAST_HOLEY_ELEMENTS | 4431 ? FAST_HOLEY_ELEMENTS |
4431 : FAST_ELEMENTS; | 4432 : FAST_ELEMENTS; |
4432 return TransitionElements(object, new_kind, isolate); | 4433 return TransitionElements(object, new_kind, isolate); |
4433 } else { | 4434 } else { |
4434 return *object; | 4435 return *object; |
4435 } | 4436 } |
4436 } | 4437 } |
4437 | 4438 |
4438 | 4439 |
4439 // Set the native flag on the function. | 4440 // Set the native flag on the function. |
4440 // This is used to decide if we should transform null and undefined | 4441 // This is used to decide if we should transform null and undefined |
4441 // into the global object when doing call and apply. | 4442 // into the global object when doing call and apply. |
4442 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 4443 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { |
4443 NoHandleAllocation ha; | 4444 NoHandleAllocation ha(isolate); |
4444 RUNTIME_ASSERT(args.length() == 1); | 4445 RUNTIME_ASSERT(args.length() == 1); |
4445 | 4446 |
4446 Handle<Object> object = args.at<Object>(0); | 4447 Handle<Object> object = args.at<Object>(0); |
4447 | 4448 |
4448 if (object->IsJSFunction()) { | 4449 if (object->IsJSFunction()) { |
4449 JSFunction* func = JSFunction::cast(*object); | 4450 JSFunction* func = JSFunction::cast(*object); |
4450 func->shared()->set_native(true); | 4451 func->shared()->set_native(true); |
4451 } | 4452 } |
4452 return isolate->heap()->undefined_value(); | 4453 return isolate->heap()->undefined_value(); |
4453 } | 4454 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4536 debug->ClearStepOut(); | 4537 debug->ClearStepOut(); |
4537 debug->FloodWithOneShot(callback); | 4538 debug->FloodWithOneShot(callback); |
4538 #endif // ENABLE_DEBUGGER_SUPPORT | 4539 #endif // ENABLE_DEBUGGER_SUPPORT |
4539 return isolate->heap()->undefined_value(); | 4540 return isolate->heap()->undefined_value(); |
4540 } | 4541 } |
4541 | 4542 |
4542 | 4543 |
4543 // Set a local property, even if it is READ_ONLY. If the property does not | 4544 // Set a local property, even if it is READ_ONLY. If the property does not |
4544 // exist, it will be added with attributes NONE. | 4545 // exist, it will be added with attributes NONE. |
4545 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { | 4546 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { |
4546 NoHandleAllocation ha; | 4547 NoHandleAllocation ha(isolate); |
4547 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 4548 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
4548 CONVERT_ARG_CHECKED(JSObject, object, 0); | 4549 CONVERT_ARG_CHECKED(JSObject, object, 0); |
4549 CONVERT_ARG_CHECKED(String, name, 1); | 4550 CONVERT_ARG_CHECKED(String, name, 1); |
4550 // Compute attributes. | 4551 // Compute attributes. |
4551 PropertyAttributes attributes = NONE; | 4552 PropertyAttributes attributes = NONE; |
4552 if (args.length() == 4) { | 4553 if (args.length() == 4) { |
4553 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); | 4554 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
4554 // Only attribute bits should be set. | 4555 // Only attribute bits should be set. |
4555 RUNTIME_ASSERT( | 4556 RUNTIME_ASSERT( |
4556 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4557 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4557 attributes = static_cast<PropertyAttributes>(unchecked_value); | 4558 attributes = static_cast<PropertyAttributes>(unchecked_value); |
4558 } | 4559 } |
4559 | 4560 |
4560 return object-> | 4561 return object-> |
4561 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 4562 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
4562 } | 4563 } |
4563 | 4564 |
4564 | 4565 |
4565 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 4566 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
4566 NoHandleAllocation ha; | 4567 NoHandleAllocation ha(isolate); |
4567 ASSERT(args.length() == 3); | 4568 ASSERT(args.length() == 3); |
4568 | 4569 |
4569 CONVERT_ARG_CHECKED(JSReceiver, object, 0); | 4570 CONVERT_ARG_CHECKED(JSReceiver, object, 0); |
4570 CONVERT_ARG_CHECKED(String, key, 1); | 4571 CONVERT_ARG_CHECKED(String, key, 1); |
4571 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 4572 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
4572 return object->DeleteProperty(key, (strict_mode == kStrictMode) | 4573 return object->DeleteProperty(key, (strict_mode == kStrictMode) |
4573 ? JSReceiver::STRICT_DELETION | 4574 ? JSReceiver::STRICT_DELETION |
4574 : JSReceiver::NORMAL_DELETION); | 4575 : JSReceiver::NORMAL_DELETION); |
4575 } | 4576 } |
4576 | 4577 |
4577 | 4578 |
4578 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 4579 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
4579 Handle<JSObject> object, | 4580 Handle<JSObject> object, |
4580 Handle<String> key) { | 4581 Handle<String> key) { |
4581 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 4582 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
4582 // Handle hidden prototypes. If there's a hidden prototype above this thing | 4583 // Handle hidden prototypes. If there's a hidden prototype above this thing |
4583 // then we have to check it for properties, because they are supposed to | 4584 // then we have to check it for properties, because they are supposed to |
4584 // look like they are on this object. | 4585 // look like they are on this object. |
4585 Handle<Object> proto(object->GetPrototype()); | 4586 Handle<Object> proto(object->GetPrototype(), isolate); |
4586 if (proto->IsJSObject() && | 4587 if (proto->IsJSObject() && |
4587 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 4588 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
4588 return HasLocalPropertyImplementation(isolate, | 4589 return HasLocalPropertyImplementation(isolate, |
4589 Handle<JSObject>::cast(proto), | 4590 Handle<JSObject>::cast(proto), |
4590 key); | 4591 key); |
4591 } | 4592 } |
4592 return isolate->heap()->false_value(); | 4593 return isolate->heap()->false_value(); |
4593 } | 4594 } |
4594 | 4595 |
4595 | 4596 |
4596 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 4597 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { |
4597 NoHandleAllocation ha; | 4598 NoHandleAllocation ha(isolate); |
4598 ASSERT(args.length() == 2); | 4599 ASSERT(args.length() == 2); |
4599 CONVERT_ARG_CHECKED(String, key, 1); | 4600 CONVERT_ARG_CHECKED(String, key, 1); |
4600 | 4601 |
4601 uint32_t index; | 4602 uint32_t index; |
4602 const bool key_is_array_index = key->AsArrayIndex(&index); | 4603 const bool key_is_array_index = key->AsArrayIndex(&index); |
4603 | 4604 |
4604 Object* obj = args[0]; | 4605 Object* obj = args[0]; |
4605 // Only JS objects can have properties. | 4606 // Only JS objects can have properties. |
4606 if (obj->IsJSObject()) { | 4607 if (obj->IsJSObject()) { |
4607 JSObject* object = JSObject::cast(obj); | 4608 JSObject* object = JSObject::cast(obj); |
(...skipping 17 matching lines...) Expand all Loading... |
4625 String* string = String::cast(obj); | 4626 String* string = String::cast(obj); |
4626 if (index < static_cast<uint32_t>(string->length())) { | 4627 if (index < static_cast<uint32_t>(string->length())) { |
4627 return isolate->heap()->true_value(); | 4628 return isolate->heap()->true_value(); |
4628 } | 4629 } |
4629 } | 4630 } |
4630 return isolate->heap()->false_value(); | 4631 return isolate->heap()->false_value(); |
4631 } | 4632 } |
4632 | 4633 |
4633 | 4634 |
4634 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 4635 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { |
4635 NoHandleAllocation na; | 4636 NoHandleAllocation na(isolate); |
4636 ASSERT(args.length() == 2); | 4637 ASSERT(args.length() == 2); |
4637 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 4638 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
4638 CONVERT_ARG_CHECKED(String, key, 1); | 4639 CONVERT_ARG_CHECKED(String, key, 1); |
4639 | 4640 |
4640 bool result = receiver->HasProperty(key); | 4641 bool result = receiver->HasProperty(key); |
4641 if (isolate->has_pending_exception()) return Failure::Exception(); | 4642 if (isolate->has_pending_exception()) return Failure::Exception(); |
4642 return isolate->heap()->ToBoolean(result); | 4643 return isolate->heap()->ToBoolean(result); |
4643 } | 4644 } |
4644 | 4645 |
4645 | 4646 |
4646 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 4647 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { |
4647 NoHandleAllocation na; | 4648 NoHandleAllocation na(isolate); |
4648 ASSERT(args.length() == 2); | 4649 ASSERT(args.length() == 2); |
4649 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 4650 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
4650 CONVERT_SMI_ARG_CHECKED(index, 1); | 4651 CONVERT_SMI_ARG_CHECKED(index, 1); |
4651 | 4652 |
4652 bool result = receiver->HasElement(index); | 4653 bool result = receiver->HasElement(index); |
4653 if (isolate->has_pending_exception()) return Failure::Exception(); | 4654 if (isolate->has_pending_exception()) return Failure::Exception(); |
4654 return isolate->heap()->ToBoolean(result); | 4655 return isolate->heap()->ToBoolean(result); |
4655 } | 4656 } |
4656 | 4657 |
4657 | 4658 |
4658 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { | 4659 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { |
4659 NoHandleAllocation ha; | 4660 NoHandleAllocation ha(isolate); |
4660 ASSERT(args.length() == 2); | 4661 ASSERT(args.length() == 2); |
4661 | 4662 |
4662 CONVERT_ARG_CHECKED(JSObject, object, 0); | 4663 CONVERT_ARG_CHECKED(JSObject, object, 0); |
4663 CONVERT_ARG_CHECKED(String, key, 1); | 4664 CONVERT_ARG_CHECKED(String, key, 1); |
4664 | 4665 |
4665 PropertyAttributes att = object->GetLocalPropertyAttribute(key); | 4666 PropertyAttributes att = object->GetLocalPropertyAttribute(key); |
4666 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); | 4667 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); |
4667 } | 4668 } |
4668 | 4669 |
4669 | 4670 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4879 | 4880 |
4880 if (object->IsJSGlobalProxy()) { | 4881 if (object->IsJSGlobalProxy()) { |
4881 // Do access checks before going to the global object. | 4882 // Do access checks before going to the global object. |
4882 if (object->IsAccessCheckNeeded() && | 4883 if (object->IsAccessCheckNeeded() && |
4883 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), | 4884 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), |
4884 v8::ACCESS_KEYS)) { | 4885 v8::ACCESS_KEYS)) { |
4885 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 4886 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); |
4886 return *isolate->factory()->NewJSArray(0); | 4887 return *isolate->factory()->NewJSArray(0); |
4887 } | 4888 } |
4888 | 4889 |
4889 Handle<Object> proto(object->GetPrototype()); | 4890 Handle<Object> proto(object->GetPrototype(), isolate); |
4890 // If proxy is detached we simply return an empty array. | 4891 // If proxy is detached we simply return an empty array. |
4891 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); | 4892 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); |
4892 object = Handle<JSObject>::cast(proto); | 4893 object = Handle<JSObject>::cast(proto); |
4893 } | 4894 } |
4894 | 4895 |
4895 bool threw = false; | 4896 bool threw = false; |
4896 Handle<FixedArray> contents = | 4897 Handle<FixedArray> contents = |
4897 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &threw); | 4898 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &threw); |
4898 if (threw) return Failure::Exception(); | 4899 if (threw) return Failure::Exception(); |
4899 | 4900 |
(...skipping 13 matching lines...) Expand all Loading... |
4913 Handle<Object> entry_str = | 4914 Handle<Object> entry_str = |
4914 isolate->factory()->NumberToString(entry_handle); | 4915 isolate->factory()->NumberToString(entry_handle); |
4915 copy->set(i, *entry_str); | 4916 copy->set(i, *entry_str); |
4916 } | 4917 } |
4917 } | 4918 } |
4918 return *isolate->factory()->NewJSArrayWithElements(copy); | 4919 return *isolate->factory()->NewJSArrayWithElements(copy); |
4919 } | 4920 } |
4920 | 4921 |
4921 | 4922 |
4922 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { | 4923 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { |
4923 NoHandleAllocation ha; | 4924 NoHandleAllocation ha(isolate); |
4924 ASSERT(args.length() == 1); | 4925 ASSERT(args.length() == 1); |
4925 | 4926 |
4926 // Compute the frame holding the arguments. | 4927 // Compute the frame holding the arguments. |
4927 JavaScriptFrameIterator it(isolate); | 4928 JavaScriptFrameIterator it(isolate); |
4928 it.AdvanceToArgumentsFrame(); | 4929 it.AdvanceToArgumentsFrame(); |
4929 JavaScriptFrame* frame = it.frame(); | 4930 JavaScriptFrame* frame = it.frame(); |
4930 | 4931 |
4931 // Get the actual number of provided arguments. | 4932 // Get the actual number of provided arguments. |
4932 const uint32_t n = frame->ComputeParametersCount(); | 4933 const uint32_t n = frame->ComputeParametersCount(); |
4933 | 4934 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4975 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 4976 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { |
4976 ASSERT(args.length() == 1); | 4977 ASSERT(args.length() == 1); |
4977 Object* object = args[0]; | 4978 Object* object = args[0]; |
4978 return (object->IsJSObject() && !object->IsGlobalObject()) | 4979 return (object->IsJSObject() && !object->IsGlobalObject()) |
4979 ? JSObject::cast(object)->TransformToFastProperties(0) | 4980 ? JSObject::cast(object)->TransformToFastProperties(0) |
4980 : object; | 4981 : object; |
4981 } | 4982 } |
4982 | 4983 |
4983 | 4984 |
4984 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 4985 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { |
4985 NoHandleAllocation ha; | 4986 NoHandleAllocation ha(isolate); |
4986 ASSERT(args.length() == 1); | 4987 ASSERT(args.length() == 1); |
4987 | 4988 |
4988 return args[0]->ToBoolean(); | 4989 return args[0]->ToBoolean(); |
4989 } | 4990 } |
4990 | 4991 |
4991 | 4992 |
4992 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 4993 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
4993 // Possible optimizations: put the type string into the oddballs. | 4994 // Possible optimizations: put the type string into the oddballs. |
4994 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { | 4995 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { |
4995 NoHandleAllocation ha; | 4996 NoHandleAllocation ha(isolate); |
4996 | 4997 |
4997 Object* obj = args[0]; | 4998 Object* obj = args[0]; |
4998 if (obj->IsNumber()) return isolate->heap()->number_symbol(); | 4999 if (obj->IsNumber()) return isolate->heap()->number_symbol(); |
4999 HeapObject* heap_obj = HeapObject::cast(obj); | 5000 HeapObject* heap_obj = HeapObject::cast(obj); |
5000 | 5001 |
5001 // typeof an undetectable object is 'undefined' | 5002 // typeof an undetectable object is 'undefined' |
5002 if (heap_obj->map()->is_undetectable()) { | 5003 if (heap_obj->map()->is_undetectable()) { |
5003 return isolate->heap()->undefined_symbol(); | 5004 return isolate->heap()->undefined_symbol(); |
5004 } | 5005 } |
5005 | 5006 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5047 | 5048 |
5048 for (int i = from + 1; i < to; i++) { | 5049 for (int i = from + 1; i < to; i++) { |
5049 d = 10 * d + (s[i] - '0'); | 5050 d = 10 * d + (s[i] - '0'); |
5050 } | 5051 } |
5051 | 5052 |
5052 return d; | 5053 return d; |
5053 } | 5054 } |
5054 | 5055 |
5055 | 5056 |
5056 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { | 5057 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { |
5057 NoHandleAllocation ha; | 5058 NoHandleAllocation ha(isolate); |
5058 ASSERT(args.length() == 1); | 5059 ASSERT(args.length() == 1); |
5059 CONVERT_ARG_CHECKED(String, subject, 0); | 5060 CONVERT_ARG_CHECKED(String, subject, 0); |
5060 subject->TryFlatten(); | 5061 subject->TryFlatten(); |
5061 | 5062 |
5062 // Fast case: short integer or some sorts of junk values. | 5063 // Fast case: short integer or some sorts of junk values. |
5063 int len = subject->length(); | 5064 int len = subject->length(); |
5064 if (subject->IsSeqOneByteString()) { | 5065 if (subject->IsSeqOneByteString()) { |
5065 if (len == 0) return Smi::FromInt(0); | 5066 if (len == 0) return Smi::FromInt(0); |
5066 | 5067 |
5067 uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); | 5068 uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5364 write_cursor - reinterpret_cast<Char*>( | 5365 write_cursor - reinterpret_cast<Char*>( |
5365 new_string->address() + SeqString::kHeaderSize)); | 5366 new_string->address() + SeqString::kHeaderSize)); |
5366 isolate->heap()->new_space()-> | 5367 isolate->heap()->new_space()-> |
5367 template ShrinkStringAtAllocationBoundary<StringType>( | 5368 template ShrinkStringAtAllocationBoundary<StringType>( |
5368 new_string, final_length); | 5369 new_string, final_length); |
5369 return new_string; | 5370 return new_string; |
5370 } | 5371 } |
5371 | 5372 |
5372 | 5373 |
5373 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { | 5374 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { |
5374 NoHandleAllocation ha; | 5375 NoHandleAllocation ha(isolate); |
5375 CONVERT_ARG_CHECKED(String, str, 0); | 5376 CONVERT_ARG_CHECKED(String, str, 0); |
5376 if (!str->IsFlat()) { | 5377 if (!str->IsFlat()) { |
5377 MaybeObject* try_flatten = str->TryFlatten(); | 5378 MaybeObject* try_flatten = str->TryFlatten(); |
5378 Object* flat; | 5379 Object* flat; |
5379 if (!try_flatten->ToObject(&flat)) { | 5380 if (!try_flatten->ToObject(&flat)) { |
5380 return try_flatten; | 5381 return try_flatten; |
5381 } | 5382 } |
5382 str = String::cast(flat); | 5383 str = String::cast(flat); |
5383 ASSERT(str->IsFlat()); | 5384 ASSERT(str->IsFlat()); |
5384 } | 5385 } |
5385 String::FlatContent flat = str->GetFlatContent(); | 5386 String::FlatContent flat = str->GetFlatContent(); |
5386 ASSERT(flat.IsFlat()); | 5387 ASSERT(flat.IsFlat()); |
5387 if (flat.IsTwoByte()) { | 5388 if (flat.IsTwoByte()) { |
5388 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, | 5389 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, |
5389 flat.ToUC16Vector()); | 5390 flat.ToUC16Vector()); |
5390 } else { | 5391 } else { |
5391 return QuoteJsonString<uint8_t, SeqOneByteString, false>( | 5392 return QuoteJsonString<uint8_t, SeqOneByteString, false>( |
5392 isolate, | 5393 isolate, |
5393 flat.ToOneByteVector()); | 5394 flat.ToOneByteVector()); |
5394 } | 5395 } |
5395 } | 5396 } |
5396 | 5397 |
5397 | 5398 |
5398 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { | 5399 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { |
5399 NoHandleAllocation ha; | 5400 NoHandleAllocation ha(isolate); |
5400 CONVERT_ARG_CHECKED(String, str, 0); | 5401 CONVERT_ARG_CHECKED(String, str, 0); |
5401 if (!str->IsFlat()) { | 5402 if (!str->IsFlat()) { |
5402 MaybeObject* try_flatten = str->TryFlatten(); | 5403 MaybeObject* try_flatten = str->TryFlatten(); |
5403 Object* flat; | 5404 Object* flat; |
5404 if (!try_flatten->ToObject(&flat)) { | 5405 if (!try_flatten->ToObject(&flat)) { |
5405 return try_flatten; | 5406 return try_flatten; |
5406 } | 5407 } |
5407 str = String::cast(flat); | 5408 str = String::cast(flat); |
5408 ASSERT(str->IsFlat()); | 5409 ASSERT(str->IsFlat()); |
5409 } | 5410 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5467 write_cursor - reinterpret_cast<Char*>( | 5468 write_cursor - reinterpret_cast<Char*>( |
5468 new_string->address() + SeqString::kHeaderSize)); | 5469 new_string->address() + SeqString::kHeaderSize)); |
5469 isolate->heap()->new_space()-> | 5470 isolate->heap()->new_space()-> |
5470 template ShrinkStringAtAllocationBoundary<StringType>( | 5471 template ShrinkStringAtAllocationBoundary<StringType>( |
5471 new_string, final_length); | 5472 new_string, final_length); |
5472 return new_string; | 5473 return new_string; |
5473 } | 5474 } |
5474 | 5475 |
5475 | 5476 |
5476 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { | 5477 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { |
5477 NoHandleAllocation ha; | 5478 NoHandleAllocation ha(isolate); |
5478 ASSERT(args.length() == 1); | 5479 ASSERT(args.length() == 1); |
5479 CONVERT_ARG_CHECKED(JSArray, array, 0); | 5480 CONVERT_ARG_CHECKED(JSArray, array, 0); |
5480 | 5481 |
5481 if (!array->HasFastObjectElements()) { | 5482 if (!array->HasFastObjectElements()) { |
5482 return isolate->heap()->undefined_value(); | 5483 return isolate->heap()->undefined_value(); |
5483 } | 5484 } |
5484 FixedArray* elements = FixedArray::cast(array->elements()); | 5485 FixedArray* elements = FixedArray::cast(array->elements()); |
5485 int n = elements->length(); | 5486 int n = elements->length(); |
5486 bool ascii = true; | 5487 bool ascii = true; |
5487 int total_length = 0; | 5488 int total_length = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
5514 elements, | 5515 elements, |
5515 worst_case_length); | 5516 worst_case_length); |
5516 } | 5517 } |
5517 } | 5518 } |
5518 | 5519 |
5519 | 5520 |
5520 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { | 5521 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { |
5521 ASSERT(args.length() == 1); | 5522 ASSERT(args.length() == 1); |
5522 HandleScope scope(isolate); | 5523 HandleScope scope(isolate); |
5523 BasicJsonStringifier stringifier(isolate); | 5524 BasicJsonStringifier stringifier(isolate); |
5524 return stringifier.Stringify(Handle<Object>(args[0])); | 5525 return stringifier.Stringify(Handle<Object>(args[0], isolate)); |
5525 } | 5526 } |
5526 | 5527 |
5527 | 5528 |
5528 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 5529 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { |
5529 NoHandleAllocation ha; | 5530 NoHandleAllocation ha(isolate); |
5530 | 5531 |
5531 CONVERT_ARG_CHECKED(String, s, 0); | 5532 CONVERT_ARG_CHECKED(String, s, 0); |
5532 CONVERT_SMI_ARG_CHECKED(radix, 1); | 5533 CONVERT_SMI_ARG_CHECKED(radix, 1); |
5533 | 5534 |
5534 s->TryFlatten(); | 5535 s->TryFlatten(); |
5535 | 5536 |
5536 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 5537 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
5537 double value = StringToInt(isolate->unicode_cache(), s, radix); | 5538 double value = StringToInt(isolate->unicode_cache(), s, radix); |
5538 return isolate->heap()->NumberFromDouble(value); | 5539 return isolate->heap()->NumberFromDouble(value); |
5539 } | 5540 } |
5540 | 5541 |
5541 | 5542 |
5542 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 5543 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { |
5543 NoHandleAllocation ha; | 5544 NoHandleAllocation ha(isolate); |
5544 CONVERT_ARG_CHECKED(String, str, 0); | 5545 CONVERT_ARG_CHECKED(String, str, 0); |
5545 | 5546 |
5546 // ECMA-262 section 15.1.2.3, empty string is NaN | 5547 // ECMA-262 section 15.1.2.3, empty string is NaN |
5547 double value = StringToDouble(isolate->unicode_cache(), | 5548 double value = StringToDouble(isolate->unicode_cache(), |
5548 str, ALLOW_TRAILING_JUNK, OS::nan_value()); | 5549 str, ALLOW_TRAILING_JUNK, OS::nan_value()); |
5549 | 5550 |
5550 // Create a number object from the value. | 5551 // Create a number object from the value. |
5551 return isolate->heap()->NumberFromDouble(value); | 5552 return isolate->heap()->NumberFromDouble(value); |
5552 } | 5553 } |
5553 | 5554 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5813 }; | 5814 }; |
5814 | 5815 |
5815 } // namespace | 5816 } // namespace |
5816 | 5817 |
5817 | 5818 |
5818 template <typename ConvertTraits> | 5819 template <typename ConvertTraits> |
5819 MUST_USE_RESULT static MaybeObject* ConvertCase( | 5820 MUST_USE_RESULT static MaybeObject* ConvertCase( |
5820 Arguments args, | 5821 Arguments args, |
5821 Isolate* isolate, | 5822 Isolate* isolate, |
5822 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { | 5823 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { |
5823 NoHandleAllocation ha; | 5824 NoHandleAllocation ha(isolate); |
5824 CONVERT_ARG_CHECKED(String, s, 0); | 5825 CONVERT_ARG_CHECKED(String, s, 0); |
5825 s = s->TryFlattenGetString(); | 5826 s = s->TryFlattenGetString(); |
5826 | 5827 |
5827 const int length = s->length(); | 5828 const int length = s->length(); |
5828 // Assume that the string is not empty; we need this assumption later | 5829 // Assume that the string is not empty; we need this assumption later |
5829 if (length == 0) return s; | 5830 if (length == 0) return s; |
5830 | 5831 |
5831 // Simpler handling of ASCII strings. | 5832 // Simpler handling of ASCII strings. |
5832 // | 5833 // |
5833 // NOTE: This assumes that the upper/lower case of an ASCII | 5834 // NOTE: This assumes that the upper/lower case of an ASCII |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5888 args, isolate, isolate->runtime_state()->to_upper_mapping()); | 5889 args, isolate, isolate->runtime_state()->to_upper_mapping()); |
5889 } | 5890 } |
5890 | 5891 |
5891 | 5892 |
5892 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { | 5893 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { |
5893 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; | 5894 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; |
5894 } | 5895 } |
5895 | 5896 |
5896 | 5897 |
5897 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { | 5898 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { |
5898 NoHandleAllocation ha; | 5899 NoHandleAllocation ha(isolate); |
5899 ASSERT(args.length() == 3); | 5900 ASSERT(args.length() == 3); |
5900 | 5901 |
5901 CONVERT_ARG_CHECKED(String, s, 0); | 5902 CONVERT_ARG_CHECKED(String, s, 0); |
5902 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); | 5903 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); |
5903 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); | 5904 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); |
5904 | 5905 |
5905 s->TryFlatten(); | 5906 s->TryFlatten(); |
5906 int length = s->length(); | 5907 int length = s->length(); |
5907 | 5908 |
5908 int left = 0; | 5909 int left = 0; |
(...skipping 18 matching lines...) Expand all Loading... |
5927 HandleScope handle_scope(isolate); | 5928 HandleScope handle_scope(isolate); |
5928 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 5929 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
5929 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 5930 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
5930 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); | 5931 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); |
5931 | 5932 |
5932 int subject_length = subject->length(); | 5933 int subject_length = subject->length(); |
5933 int pattern_length = pattern->length(); | 5934 int pattern_length = pattern->length(); |
5934 RUNTIME_ASSERT(pattern_length > 0); | 5935 RUNTIME_ASSERT(pattern_length > 0); |
5935 | 5936 |
5936 if (limit == 0xffffffffu) { | 5937 if (limit == 0xffffffffu) { |
5937 Handle<Object> cached_answer(RegExpResultsCache::Lookup( | 5938 Handle<Object> cached_answer( |
5938 isolate->heap(), | 5939 RegExpResultsCache::Lookup(isolate->heap(), |
5939 *subject, | 5940 *subject, |
5940 *pattern, | 5941 *pattern, |
5941 RegExpResultsCache::STRING_SPLIT_SUBSTRINGS)); | 5942 RegExpResultsCache::STRING_SPLIT_SUBSTRINGS), |
| 5943 isolate); |
5942 if (*cached_answer != Smi::FromInt(0)) { | 5944 if (*cached_answer != Smi::FromInt(0)) { |
5943 // The cache FixedArray is a COW-array and can therefore be reused. | 5945 // The cache FixedArray is a COW-array and can therefore be reused. |
5944 Handle<JSArray> result = | 5946 Handle<JSArray> result = |
5945 isolate->factory()->NewJSArrayWithElements( | 5947 isolate->factory()->NewJSArrayWithElements( |
5946 Handle<FixedArray>::cast(cached_answer)); | 5948 Handle<FixedArray>::cast(cached_answer)); |
5947 return *result; | 5949 return *result; |
5948 } | 5950 } |
5949 } | 5951 } |
5950 | 5952 |
5951 // The limit can be very large (0xffffffffu), but since the pattern | 5953 // The limit can be very large (0xffffffffu), but since the pattern |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6077 length); | 6079 length); |
6078 } else { | 6080 } else { |
6079 MemsetPointer(elements->data_start(), | 6081 MemsetPointer(elements->data_start(), |
6080 isolate->heap()->undefined_value(), | 6082 isolate->heap()->undefined_value(), |
6081 length); | 6083 length); |
6082 } | 6084 } |
6083 } else { | 6085 } else { |
6084 elements = isolate->factory()->NewFixedArray(length); | 6086 elements = isolate->factory()->NewFixedArray(length); |
6085 } | 6087 } |
6086 for (int i = position; i < length; ++i) { | 6088 for (int i = position; i < length; ++i) { |
6087 Handle<Object> str = LookupSingleCharacterStringFromCode(s->Get(i)); | 6089 Handle<Object> str = |
| 6090 LookupSingleCharacterStringFromCode(isolate, s->Get(i)); |
6088 elements->set(i, *str); | 6091 elements->set(i, *str); |
6089 } | 6092 } |
6090 | 6093 |
6091 #ifdef DEBUG | 6094 #ifdef DEBUG |
6092 for (int i = 0; i < length; ++i) { | 6095 for (int i = 0; i < length; ++i) { |
6093 ASSERT(String::cast(elements->get(i))->length() == 1); | 6096 ASSERT(String::cast(elements->get(i))->length() == 1); |
6094 } | 6097 } |
6095 #endif | 6098 #endif |
6096 | 6099 |
6097 return *isolate->factory()->NewJSArrayWithElements(elements); | 6100 return *isolate->factory()->NewJSArrayWithElements(elements); |
6098 } | 6101 } |
6099 | 6102 |
6100 | 6103 |
6101 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { | 6104 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { |
6102 NoHandleAllocation ha; | 6105 NoHandleAllocation ha(isolate); |
6103 ASSERT(args.length() == 1); | 6106 ASSERT(args.length() == 1); |
6104 CONVERT_ARG_CHECKED(String, value, 0); | 6107 CONVERT_ARG_CHECKED(String, value, 0); |
6105 return value->ToObject(); | 6108 return value->ToObject(); |
6106 } | 6109 } |
6107 | 6110 |
6108 | 6111 |
6109 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6112 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
6110 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6113 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
6111 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6114 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
6112 return char_length == 0; | 6115 return char_length == 0; |
6113 } | 6116 } |
6114 | 6117 |
6115 | 6118 |
6116 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { | 6119 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { |
6117 NoHandleAllocation ha; | 6120 NoHandleAllocation ha(isolate); |
6118 ASSERT(args.length() == 1); | 6121 ASSERT(args.length() == 1); |
6119 | 6122 |
6120 Object* number = args[0]; | 6123 Object* number = args[0]; |
6121 RUNTIME_ASSERT(number->IsNumber()); | 6124 RUNTIME_ASSERT(number->IsNumber()); |
6122 | 6125 |
6123 return isolate->heap()->NumberToString(number); | 6126 return isolate->heap()->NumberToString(number); |
6124 } | 6127 } |
6125 | 6128 |
6126 | 6129 |
6127 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { | 6130 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { |
6128 NoHandleAllocation ha; | 6131 NoHandleAllocation ha(isolate); |
6129 ASSERT(args.length() == 1); | 6132 ASSERT(args.length() == 1); |
6130 | 6133 |
6131 Object* number = args[0]; | 6134 Object* number = args[0]; |
6132 RUNTIME_ASSERT(number->IsNumber()); | 6135 RUNTIME_ASSERT(number->IsNumber()); |
6133 | 6136 |
6134 return isolate->heap()->NumberToString(number, false); | 6137 return isolate->heap()->NumberToString(number, false); |
6135 } | 6138 } |
6136 | 6139 |
6137 | 6140 |
6138 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6141 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { |
6139 NoHandleAllocation ha; | 6142 NoHandleAllocation ha(isolate); |
6140 ASSERT(args.length() == 1); | 6143 ASSERT(args.length() == 1); |
6141 | 6144 |
6142 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6145 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6143 | 6146 |
6144 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6147 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
6145 if (number > 0 && number <= Smi::kMaxValue) { | 6148 if (number > 0 && number <= Smi::kMaxValue) { |
6146 return Smi::FromInt(static_cast<int>(number)); | 6149 return Smi::FromInt(static_cast<int>(number)); |
6147 } | 6150 } |
6148 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); | 6151 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); |
6149 } | 6152 } |
6150 | 6153 |
6151 | 6154 |
6152 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { | 6155 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { |
6153 NoHandleAllocation ha; | 6156 NoHandleAllocation ha(isolate); |
6154 ASSERT(args.length() == 1); | 6157 ASSERT(args.length() == 1); |
6155 | 6158 |
6156 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6159 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6157 | 6160 |
6158 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6161 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
6159 if (number > 0 && number <= Smi::kMaxValue) { | 6162 if (number > 0 && number <= Smi::kMaxValue) { |
6160 return Smi::FromInt(static_cast<int>(number)); | 6163 return Smi::FromInt(static_cast<int>(number)); |
6161 } | 6164 } |
6162 | 6165 |
6163 double double_value = DoubleToInteger(number); | 6166 double double_value = DoubleToInteger(number); |
6164 // Map both -0 and +0 to +0. | 6167 // Map both -0 and +0 to +0. |
6165 if (double_value == 0) double_value = 0; | 6168 if (double_value == 0) double_value = 0; |
6166 | 6169 |
6167 return isolate->heap()->NumberFromDouble(double_value); | 6170 return isolate->heap()->NumberFromDouble(double_value); |
6168 } | 6171 } |
6169 | 6172 |
6170 | 6173 |
6171 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { | 6174 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { |
6172 NoHandleAllocation ha; | 6175 NoHandleAllocation ha(isolate); |
6173 ASSERT(args.length() == 1); | 6176 ASSERT(args.length() == 1); |
6174 | 6177 |
6175 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 6178 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
6176 return isolate->heap()->NumberFromUint32(number); | 6179 return isolate->heap()->NumberFromUint32(number); |
6177 } | 6180 } |
6178 | 6181 |
6179 | 6182 |
6180 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { | 6183 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { |
6181 NoHandleAllocation ha; | 6184 NoHandleAllocation ha(isolate); |
6182 ASSERT(args.length() == 1); | 6185 ASSERT(args.length() == 1); |
6183 | 6186 |
6184 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6187 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6185 | 6188 |
6186 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6189 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
6187 if (number > 0 && number <= Smi::kMaxValue) { | 6190 if (number > 0 && number <= Smi::kMaxValue) { |
6188 return Smi::FromInt(static_cast<int>(number)); | 6191 return Smi::FromInt(static_cast<int>(number)); |
6189 } | 6192 } |
6190 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); | 6193 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); |
6191 } | 6194 } |
6192 | 6195 |
6193 | 6196 |
6194 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6197 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
6195 // a small integer. | 6198 // a small integer. |
6196 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { | 6199 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { |
6197 NoHandleAllocation ha; | 6200 NoHandleAllocation ha(isolate); |
6198 ASSERT(args.length() == 1); | 6201 ASSERT(args.length() == 1); |
6199 | 6202 |
6200 Object* obj = args[0]; | 6203 Object* obj = args[0]; |
6201 if (obj->IsSmi()) { | 6204 if (obj->IsSmi()) { |
6202 return obj; | 6205 return obj; |
6203 } | 6206 } |
6204 if (obj->IsHeapNumber()) { | 6207 if (obj->IsHeapNumber()) { |
6205 double value = HeapNumber::cast(obj)->value(); | 6208 double value = HeapNumber::cast(obj)->value(); |
6206 int int_value = FastD2I(value); | 6209 int int_value = FastD2I(value); |
6207 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6210 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
6208 return Smi::FromInt(int_value); | 6211 return Smi::FromInt(int_value); |
6209 } | 6212 } |
6210 } | 6213 } |
6211 return isolate->heap()->nan_value(); | 6214 return isolate->heap()->nan_value(); |
6212 } | 6215 } |
6213 | 6216 |
6214 | 6217 |
6215 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { | 6218 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { |
6216 NoHandleAllocation ha; | 6219 NoHandleAllocation ha(isolate); |
6217 ASSERT(args.length() == 0); | 6220 ASSERT(args.length() == 0); |
6218 return isolate->heap()->AllocateHeapNumber(0); | 6221 return isolate->heap()->AllocateHeapNumber(0); |
6219 } | 6222 } |
6220 | 6223 |
6221 | 6224 |
6222 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 6225 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { |
6223 NoHandleAllocation ha; | 6226 NoHandleAllocation ha(isolate); |
6224 ASSERT(args.length() == 2); | 6227 ASSERT(args.length() == 2); |
6225 | 6228 |
6226 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6229 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6227 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6230 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6228 return isolate->heap()->NumberFromDouble(x + y); | 6231 return isolate->heap()->NumberFromDouble(x + y); |
6229 } | 6232 } |
6230 | 6233 |
6231 | 6234 |
6232 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { | 6235 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { |
6233 NoHandleAllocation ha; | 6236 NoHandleAllocation ha(isolate); |
6234 ASSERT(args.length() == 2); | 6237 ASSERT(args.length() == 2); |
6235 | 6238 |
6236 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6239 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6237 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6240 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6238 return isolate->heap()->NumberFromDouble(x - y); | 6241 return isolate->heap()->NumberFromDouble(x - y); |
6239 } | 6242 } |
6240 | 6243 |
6241 | 6244 |
6242 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { | 6245 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { |
6243 NoHandleAllocation ha; | 6246 NoHandleAllocation ha(isolate); |
6244 ASSERT(args.length() == 2); | 6247 ASSERT(args.length() == 2); |
6245 | 6248 |
6246 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6249 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6247 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6250 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6248 return isolate->heap()->NumberFromDouble(x * y); | 6251 return isolate->heap()->NumberFromDouble(x * y); |
6249 } | 6252 } |
6250 | 6253 |
6251 | 6254 |
6252 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { | 6255 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { |
6253 NoHandleAllocation ha; | 6256 NoHandleAllocation ha(isolate); |
6254 ASSERT(args.length() == 1); | 6257 ASSERT(args.length() == 1); |
6255 | 6258 |
6256 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6259 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6257 return isolate->heap()->NumberFromDouble(-x); | 6260 return isolate->heap()->NumberFromDouble(-x); |
6258 } | 6261 } |
6259 | 6262 |
6260 | 6263 |
6261 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { | 6264 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { |
6262 NoHandleAllocation ha; | 6265 NoHandleAllocation ha(isolate); |
6263 ASSERT(args.length() == 0); | 6266 ASSERT(args.length() == 0); |
6264 | 6267 |
6265 return isolate->heap()->NumberFromDouble(9876543210.0); | 6268 return isolate->heap()->NumberFromDouble(9876543210.0); |
6266 } | 6269 } |
6267 | 6270 |
6268 | 6271 |
6269 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { | 6272 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { |
6270 NoHandleAllocation ha; | 6273 NoHandleAllocation ha(isolate); |
6271 ASSERT(args.length() == 2); | 6274 ASSERT(args.length() == 2); |
6272 | 6275 |
6273 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6276 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6274 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6277 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6275 return isolate->heap()->NumberFromDouble(x / y); | 6278 return isolate->heap()->NumberFromDouble(x / y); |
6276 } | 6279 } |
6277 | 6280 |
6278 | 6281 |
6279 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { | 6282 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { |
6280 NoHandleAllocation ha; | 6283 NoHandleAllocation ha(isolate); |
6281 ASSERT(args.length() == 2); | 6284 ASSERT(args.length() == 2); |
6282 | 6285 |
6283 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6286 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6284 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6287 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6285 | 6288 |
6286 x = modulo(x, y); | 6289 x = modulo(x, y); |
6287 // NumberFromDouble may return a Smi instead of a Number object | 6290 // NumberFromDouble may return a Smi instead of a Number object |
6288 return isolate->heap()->NumberFromDouble(x); | 6291 return isolate->heap()->NumberFromDouble(x); |
6289 } | 6292 } |
6290 | 6293 |
6291 | 6294 |
6292 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { | 6295 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { |
6293 NoHandleAllocation ha; | 6296 NoHandleAllocation ha(isolate); |
6294 ASSERT(args.length() == 2); | 6297 ASSERT(args.length() == 2); |
6295 CONVERT_ARG_CHECKED(String, str1, 0); | 6298 CONVERT_ARG_CHECKED(String, str1, 0); |
6296 CONVERT_ARG_CHECKED(String, str2, 1); | 6299 CONVERT_ARG_CHECKED(String, str2, 1); |
6297 isolate->counters()->string_add_runtime()->Increment(); | 6300 isolate->counters()->string_add_runtime()->Increment(); |
6298 return isolate->heap()->AllocateConsString(str1, str2); | 6301 return isolate->heap()->AllocateConsString(str1, str2); |
6299 } | 6302 } |
6300 | 6303 |
6301 | 6304 |
6302 template <typename sinkchar> | 6305 template <typename sinkchar> |
6303 static inline void StringBuilderConcatHelper(String* special, | 6306 static inline void StringBuilderConcatHelper(String* special, |
(...skipping 28 matching lines...) Expand all Loading... |
6332 String* string = String::cast(element); | 6335 String* string = String::cast(element); |
6333 int element_length = string->length(); | 6336 int element_length = string->length(); |
6334 String::WriteToFlat(string, sink + position, 0, element_length); | 6337 String::WriteToFlat(string, sink + position, 0, element_length); |
6335 position += element_length; | 6338 position += element_length; |
6336 } | 6339 } |
6337 } | 6340 } |
6338 } | 6341 } |
6339 | 6342 |
6340 | 6343 |
6341 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { | 6344 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { |
6342 NoHandleAllocation ha; | 6345 NoHandleAllocation ha(isolate); |
6343 ASSERT(args.length() == 3); | 6346 ASSERT(args.length() == 3); |
6344 CONVERT_ARG_CHECKED(JSArray, array, 0); | 6347 CONVERT_ARG_CHECKED(JSArray, array, 0); |
6345 if (!args[1]->IsSmi()) { | 6348 if (!args[1]->IsSmi()) { |
6346 isolate->context()->mark_out_of_memory(); | 6349 isolate->context()->mark_out_of_memory(); |
6347 return Failure::OutOfMemoryException(0x14); | 6350 return Failure::OutOfMemoryException(0x14); |
6348 } | 6351 } |
6349 int array_length = args.smi_at(1); | 6352 int array_length = args.smi_at(1); |
6350 CONVERT_ARG_CHECKED(String, special, 2); | 6353 CONVERT_ARG_CHECKED(String, special, 2); |
6351 | 6354 |
6352 // This assumption is used by the slice encoding in one or two smis. | 6355 // This assumption is used by the slice encoding in one or two smis. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6449 StringBuilderConcatHelper(special, | 6452 StringBuilderConcatHelper(special, |
6450 answer->GetChars(), | 6453 answer->GetChars(), |
6451 fixed_array, | 6454 fixed_array, |
6452 array_length); | 6455 array_length); |
6453 return answer; | 6456 return answer; |
6454 } | 6457 } |
6455 } | 6458 } |
6456 | 6459 |
6457 | 6460 |
6458 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { | 6461 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { |
6459 NoHandleAllocation ha; | 6462 NoHandleAllocation ha(isolate); |
6460 ASSERT(args.length() == 3); | 6463 ASSERT(args.length() == 3); |
6461 CONVERT_ARG_CHECKED(JSArray, array, 0); | 6464 CONVERT_ARG_CHECKED(JSArray, array, 0); |
6462 if (!args[1]->IsSmi()) { | 6465 if (!args[1]->IsSmi()) { |
6463 isolate->context()->mark_out_of_memory(); | 6466 isolate->context()->mark_out_of_memory(); |
6464 return Failure::OutOfMemoryException(0x16); | 6467 return Failure::OutOfMemoryException(0x16); |
6465 } | 6468 } |
6466 int array_length = args.smi_at(1); | 6469 int array_length = args.smi_at(1); |
6467 CONVERT_ARG_CHECKED(String, separator, 2); | 6470 CONVERT_ARG_CHECKED(String, separator, 2); |
6468 | 6471 |
6469 if (!array->HasFastObjectElements()) { | 6472 if (!array->HasFastObjectElements()) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6574 0, separator_length); | 6577 0, separator_length); |
6575 cursor += separator_length; | 6578 cursor += separator_length; |
6576 previous_separator_position++; | 6579 previous_separator_position++; |
6577 } | 6580 } |
6578 } | 6581 } |
6579 ASSERT(cursor <= buffer.length()); | 6582 ASSERT(cursor <= buffer.length()); |
6580 } | 6583 } |
6581 | 6584 |
6582 | 6585 |
6583 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { | 6586 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { |
6584 NoHandleAllocation ha; | 6587 NoHandleAllocation ha(isolate); |
6585 ASSERT(args.length() == 3); | 6588 ASSERT(args.length() == 3); |
6586 CONVERT_ARG_CHECKED(JSArray, elements_array, 0); | 6589 CONVERT_ARG_CHECKED(JSArray, elements_array, 0); |
6587 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); | 6590 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); |
6588 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 6591 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
6589 CONVERT_ARG_CHECKED(String, separator, 2); | 6592 CONVERT_ARG_CHECKED(String, separator, 2); |
6590 // elements_array is fast-mode JSarray of alternating positions | 6593 // elements_array is fast-mode JSarray of alternating positions |
6591 // (increasing order) and strings. | 6594 // (increasing order) and strings. |
6592 // array_length is length of original array (used to add separators); | 6595 // array_length is length of original array (used to add separators); |
6593 // separator is string to put between elements. Assumed to be non-empty. | 6596 // separator is string to put between elements. Assumed to be non-empty. |
6594 | 6597 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6670 array_length, | 6673 array_length, |
6671 separator, | 6674 separator, |
6672 Vector<uc16>(result_string->GetChars(), | 6675 Vector<uc16>(result_string->GetChars(), |
6673 string_length)); | 6676 string_length)); |
6674 return result_string; | 6677 return result_string; |
6675 } | 6678 } |
6676 } | 6679 } |
6677 | 6680 |
6678 | 6681 |
6679 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { | 6682 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { |
6680 NoHandleAllocation ha; | 6683 NoHandleAllocation ha(isolate); |
6681 ASSERT(args.length() == 2); | 6684 ASSERT(args.length() == 2); |
6682 | 6685 |
6683 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6686 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6684 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6687 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6685 return isolate->heap()->NumberFromInt32(x | y); | 6688 return isolate->heap()->NumberFromInt32(x | y); |
6686 } | 6689 } |
6687 | 6690 |
6688 | 6691 |
6689 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { | 6692 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { |
6690 NoHandleAllocation ha; | 6693 NoHandleAllocation ha(isolate); |
6691 ASSERT(args.length() == 2); | 6694 ASSERT(args.length() == 2); |
6692 | 6695 |
6693 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6696 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6694 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6697 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6695 return isolate->heap()->NumberFromInt32(x & y); | 6698 return isolate->heap()->NumberFromInt32(x & y); |
6696 } | 6699 } |
6697 | 6700 |
6698 | 6701 |
6699 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { | 6702 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { |
6700 NoHandleAllocation ha; | 6703 NoHandleAllocation ha(isolate); |
6701 ASSERT(args.length() == 2); | 6704 ASSERT(args.length() == 2); |
6702 | 6705 |
6703 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6706 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6704 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6707 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6705 return isolate->heap()->NumberFromInt32(x ^ y); | 6708 return isolate->heap()->NumberFromInt32(x ^ y); |
6706 } | 6709 } |
6707 | 6710 |
6708 | 6711 |
6709 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { | 6712 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { |
6710 NoHandleAllocation ha; | 6713 NoHandleAllocation ha(isolate); |
6711 ASSERT(args.length() == 1); | 6714 ASSERT(args.length() == 1); |
6712 | 6715 |
6713 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6716 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6714 return isolate->heap()->NumberFromInt32(~x); | 6717 return isolate->heap()->NumberFromInt32(~x); |
6715 } | 6718 } |
6716 | 6719 |
6717 | 6720 |
6718 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { | 6721 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { |
6719 NoHandleAllocation ha; | 6722 NoHandleAllocation ha(isolate); |
6720 ASSERT(args.length() == 2); | 6723 ASSERT(args.length() == 2); |
6721 | 6724 |
6722 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6725 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6723 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6726 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6724 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); | 6727 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); |
6725 } | 6728 } |
6726 | 6729 |
6727 | 6730 |
6728 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { | 6731 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { |
6729 NoHandleAllocation ha; | 6732 NoHandleAllocation ha(isolate); |
6730 ASSERT(args.length() == 2); | 6733 ASSERT(args.length() == 2); |
6731 | 6734 |
6732 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 6735 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
6733 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6736 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6734 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); | 6737 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); |
6735 } | 6738 } |
6736 | 6739 |
6737 | 6740 |
6738 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { | 6741 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { |
6739 NoHandleAllocation ha; | 6742 NoHandleAllocation ha(isolate); |
6740 ASSERT(args.length() == 2); | 6743 ASSERT(args.length() == 2); |
6741 | 6744 |
6742 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6745 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6743 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6746 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6744 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); | 6747 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); |
6745 } | 6748 } |
6746 | 6749 |
6747 | 6750 |
6748 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { | 6751 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { |
6749 NoHandleAllocation ha; | 6752 NoHandleAllocation ha(isolate); |
6750 ASSERT(args.length() == 2); | 6753 ASSERT(args.length() == 2); |
6751 | 6754 |
6752 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6755 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6753 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6756 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6754 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); | 6757 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); |
6755 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); | 6758 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); |
6756 if (x == y) return Smi::FromInt(EQUAL); | 6759 if (x == y) return Smi::FromInt(EQUAL); |
6757 Object* result; | 6760 Object* result; |
6758 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 6761 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
6759 result = Smi::FromInt(EQUAL); | 6762 result = Smi::FromInt(EQUAL); |
6760 } else { | 6763 } else { |
6761 result = Smi::FromInt(NOT_EQUAL); | 6764 result = Smi::FromInt(NOT_EQUAL); |
6762 } | 6765 } |
6763 return result; | 6766 return result; |
6764 } | 6767 } |
6765 | 6768 |
6766 | 6769 |
6767 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { | 6770 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { |
6768 NoHandleAllocation ha; | 6771 NoHandleAllocation ha(isolate); |
6769 ASSERT(args.length() == 2); | 6772 ASSERT(args.length() == 2); |
6770 | 6773 |
6771 CONVERT_ARG_CHECKED(String, x, 0); | 6774 CONVERT_ARG_CHECKED(String, x, 0); |
6772 CONVERT_ARG_CHECKED(String, y, 1); | 6775 CONVERT_ARG_CHECKED(String, y, 1); |
6773 | 6776 |
6774 bool not_equal = !x->Equals(y); | 6777 bool not_equal = !x->Equals(y); |
6775 // This is slightly convoluted because the value that signifies | 6778 // This is slightly convoluted because the value that signifies |
6776 // equality is 0 and inequality is 1 so we have to negate the result | 6779 // equality is 0 and inequality is 1 so we have to negate the result |
6777 // from String::Equals. | 6780 // from String::Equals. |
6778 ASSERT(not_equal == 0 || not_equal == 1); | 6781 ASSERT(not_equal == 0 || not_equal == 1); |
6779 STATIC_CHECK(EQUAL == 0); | 6782 STATIC_CHECK(EQUAL == 0); |
6780 STATIC_CHECK(NOT_EQUAL == 1); | 6783 STATIC_CHECK(NOT_EQUAL == 1); |
6781 return Smi::FromInt(not_equal); | 6784 return Smi::FromInt(not_equal); |
6782 } | 6785 } |
6783 | 6786 |
6784 | 6787 |
6785 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { | 6788 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { |
6786 NoHandleAllocation ha; | 6789 NoHandleAllocation ha(isolate); |
6787 ASSERT(args.length() == 3); | 6790 ASSERT(args.length() == 3); |
6788 | 6791 |
6789 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6792 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6790 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6793 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6791 if (isnan(x) || isnan(y)) return args[2]; | 6794 if (isnan(x) || isnan(y)) return args[2]; |
6792 if (x == y) return Smi::FromInt(EQUAL); | 6795 if (x == y) return Smi::FromInt(EQUAL); |
6793 if (isless(x, y)) return Smi::FromInt(LESS); | 6796 if (isless(x, y)) return Smi::FromInt(LESS); |
6794 return Smi::FromInt(GREATER); | 6797 return Smi::FromInt(GREATER); |
6795 } | 6798 } |
6796 | 6799 |
6797 | 6800 |
6798 // Compare two Smis as if they were converted to strings and then | 6801 // Compare two Smis as if they were converted to strings and then |
6799 // compared lexicographically. | 6802 // compared lexicographically. |
6800 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { | 6803 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { |
6801 NoHandleAllocation ha; | 6804 NoHandleAllocation ha(isolate); |
6802 ASSERT(args.length() == 2); | 6805 ASSERT(args.length() == 2); |
6803 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 6806 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
6804 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 6807 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
6805 | 6808 |
6806 // If the integers are equal so are the string representations. | 6809 // If the integers are equal so are the string representations. |
6807 if (x_value == y_value) return Smi::FromInt(EQUAL); | 6810 if (x_value == y_value) return Smi::FromInt(EQUAL); |
6808 | 6811 |
6809 // If one of the integers is zero the normal integer order is the | 6812 // If one of the integers is zero the normal integer order is the |
6810 // same as the lexicographic order of the string representations. | 6813 // same as the lexicographic order of the string representations. |
6811 if (x_value == 0 || y_value == 0) | 6814 if (x_value == 0 || y_value == 0) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6929 } else { | 6932 } else { |
6930 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 6933 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
6931 } | 6934 } |
6932 ASSERT(result == | 6935 ASSERT(result == |
6933 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); | 6936 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); |
6934 return result; | 6937 return result; |
6935 } | 6938 } |
6936 | 6939 |
6937 | 6940 |
6938 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { | 6941 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { |
6939 NoHandleAllocation ha; | 6942 NoHandleAllocation ha(isolate); |
6940 ASSERT(args.length() == 2); | 6943 ASSERT(args.length() == 2); |
6941 | 6944 |
6942 CONVERT_ARG_CHECKED(String, x, 0); | 6945 CONVERT_ARG_CHECKED(String, x, 0); |
6943 CONVERT_ARG_CHECKED(String, y, 1); | 6946 CONVERT_ARG_CHECKED(String, y, 1); |
6944 | 6947 |
6945 isolate->counters()->string_compare_runtime()->Increment(); | 6948 isolate->counters()->string_compare_runtime()->Increment(); |
6946 | 6949 |
6947 // A few fast case tests before we flatten. | 6950 // A few fast case tests before we flatten. |
6948 if (x == y) return Smi::FromInt(EQUAL); | 6951 if (x == y) return Smi::FromInt(EQUAL); |
6949 if (y->length() == 0) { | 6952 if (y->length() == 0) { |
(...skipping 14 matching lines...) Expand all Loading... |
6964 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); | 6967 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); |
6965 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6968 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6966 } | 6969 } |
6967 | 6970 |
6968 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) | 6971 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) |
6969 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); | 6972 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); |
6970 } | 6973 } |
6971 | 6974 |
6972 | 6975 |
6973 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { | 6976 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { |
6974 NoHandleAllocation ha; | 6977 NoHandleAllocation ha(isolate); |
6975 ASSERT(args.length() == 1); | 6978 ASSERT(args.length() == 1); |
6976 isolate->counters()->math_acos()->Increment(); | 6979 isolate->counters()->math_acos()->Increment(); |
6977 | 6980 |
6978 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6981 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6979 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); | 6982 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); |
6980 } | 6983 } |
6981 | 6984 |
6982 | 6985 |
6983 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { | 6986 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { |
6984 NoHandleAllocation ha; | 6987 NoHandleAllocation ha(isolate); |
6985 ASSERT(args.length() == 1); | 6988 ASSERT(args.length() == 1); |
6986 isolate->counters()->math_asin()->Increment(); | 6989 isolate->counters()->math_asin()->Increment(); |
6987 | 6990 |
6988 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6991 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6989 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); | 6992 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); |
6990 } | 6993 } |
6991 | 6994 |
6992 | 6995 |
6993 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { | 6996 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { |
6994 NoHandleAllocation ha; | 6997 NoHandleAllocation ha(isolate); |
6995 ASSERT(args.length() == 1); | 6998 ASSERT(args.length() == 1); |
6996 isolate->counters()->math_atan()->Increment(); | 6999 isolate->counters()->math_atan()->Increment(); |
6997 | 7000 |
6998 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7001 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6999 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); | 7002 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); |
7000 } | 7003 } |
7001 | 7004 |
7002 | 7005 |
7003 static const double kPiDividedBy4 = 0.78539816339744830962; | 7006 static const double kPiDividedBy4 = 0.78539816339744830962; |
7004 | 7007 |
7005 | 7008 |
7006 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { | 7009 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { |
7007 NoHandleAllocation ha; | 7010 NoHandleAllocation ha(isolate); |
7008 ASSERT(args.length() == 2); | 7011 ASSERT(args.length() == 2); |
7009 isolate->counters()->math_atan2()->Increment(); | 7012 isolate->counters()->math_atan2()->Increment(); |
7010 | 7013 |
7011 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7014 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7012 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7015 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7013 double result; | 7016 double result; |
7014 if (isinf(x) && isinf(y)) { | 7017 if (isinf(x) && isinf(y)) { |
7015 // Make sure that the result in case of two infinite arguments | 7018 // Make sure that the result in case of two infinite arguments |
7016 // is a multiple of Pi / 4. The sign of the result is determined | 7019 // is a multiple of Pi / 4. The sign of the result is determined |
7017 // by the first argument (x) and the sign of the second argument | 7020 // by the first argument (x) and the sign of the second argument |
7018 // determines the multiplier: one or three. | 7021 // determines the multiplier: one or three. |
7019 int multiplier = (x < 0) ? -1 : 1; | 7022 int multiplier = (x < 0) ? -1 : 1; |
7020 if (y < 0) multiplier *= 3; | 7023 if (y < 0) multiplier *= 3; |
7021 result = multiplier * kPiDividedBy4; | 7024 result = multiplier * kPiDividedBy4; |
7022 } else { | 7025 } else { |
7023 result = atan2(x, y); | 7026 result = atan2(x, y); |
7024 } | 7027 } |
7025 return isolate->heap()->AllocateHeapNumber(result); | 7028 return isolate->heap()->AllocateHeapNumber(result); |
7026 } | 7029 } |
7027 | 7030 |
7028 | 7031 |
7029 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { | 7032 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { |
7030 NoHandleAllocation ha; | 7033 NoHandleAllocation ha(isolate); |
7031 ASSERT(args.length() == 1); | 7034 ASSERT(args.length() == 1); |
7032 isolate->counters()->math_ceil()->Increment(); | 7035 isolate->counters()->math_ceil()->Increment(); |
7033 | 7036 |
7034 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7037 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7035 return isolate->heap()->NumberFromDouble(ceiling(x)); | 7038 return isolate->heap()->NumberFromDouble(ceiling(x)); |
7036 } | 7039 } |
7037 | 7040 |
7038 | 7041 |
7039 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { | 7042 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { |
7040 NoHandleAllocation ha; | 7043 NoHandleAllocation ha(isolate); |
7041 ASSERT(args.length() == 1); | 7044 ASSERT(args.length() == 1); |
7042 isolate->counters()->math_cos()->Increment(); | 7045 isolate->counters()->math_cos()->Increment(); |
7043 | 7046 |
7044 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7047 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7045 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); | 7048 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); |
7046 } | 7049 } |
7047 | 7050 |
7048 | 7051 |
7049 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { | 7052 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { |
7050 NoHandleAllocation ha; | 7053 NoHandleAllocation ha(isolate); |
7051 ASSERT(args.length() == 1); | 7054 ASSERT(args.length() == 1); |
7052 isolate->counters()->math_exp()->Increment(); | 7055 isolate->counters()->math_exp()->Increment(); |
7053 | 7056 |
7054 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7057 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7055 lazily_initialize_fast_exp(); | 7058 lazily_initialize_fast_exp(); |
7056 return isolate->heap()->NumberFromDouble(fast_exp(x)); | 7059 return isolate->heap()->NumberFromDouble(fast_exp(x)); |
7057 } | 7060 } |
7058 | 7061 |
7059 | 7062 |
7060 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { | 7063 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { |
7061 NoHandleAllocation ha; | 7064 NoHandleAllocation ha(isolate); |
7062 ASSERT(args.length() == 1); | 7065 ASSERT(args.length() == 1); |
7063 isolate->counters()->math_floor()->Increment(); | 7066 isolate->counters()->math_floor()->Increment(); |
7064 | 7067 |
7065 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7068 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7066 return isolate->heap()->NumberFromDouble(floor(x)); | 7069 return isolate->heap()->NumberFromDouble(floor(x)); |
7067 } | 7070 } |
7068 | 7071 |
7069 | 7072 |
7070 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { | 7073 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { |
7071 NoHandleAllocation ha; | 7074 NoHandleAllocation ha(isolate); |
7072 ASSERT(args.length() == 1); | 7075 ASSERT(args.length() == 1); |
7073 isolate->counters()->math_log()->Increment(); | 7076 isolate->counters()->math_log()->Increment(); |
7074 | 7077 |
7075 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7078 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7076 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); | 7079 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); |
7077 } | 7080 } |
7078 | 7081 |
7079 // Slow version of Math.pow. We check for fast paths for special cases. | 7082 // Slow version of Math.pow. We check for fast paths for special cases. |
7080 // Used if SSE2/VFP3 is not available. | 7083 // Used if SSE2/VFP3 is not available. |
7081 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { | 7084 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { |
7082 NoHandleAllocation ha; | 7085 NoHandleAllocation ha(isolate); |
7083 ASSERT(args.length() == 2); | 7086 ASSERT(args.length() == 2); |
7084 isolate->counters()->math_pow()->Increment(); | 7087 isolate->counters()->math_pow()->Increment(); |
7085 | 7088 |
7086 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7089 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7087 | 7090 |
7088 // If the second argument is a smi, it is much faster to call the | 7091 // If the second argument is a smi, it is much faster to call the |
7089 // custom powi() function than the generic pow(). | 7092 // custom powi() function than the generic pow(). |
7090 if (args[1]->IsSmi()) { | 7093 if (args[1]->IsSmi()) { |
7091 int y = args.smi_at(1); | 7094 int y = args.smi_at(1); |
7092 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); | 7095 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); |
7093 } | 7096 } |
7094 | 7097 |
7095 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7098 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7096 double result = power_helper(x, y); | 7099 double result = power_helper(x, y); |
7097 if (isnan(result)) return isolate->heap()->nan_value(); | 7100 if (isnan(result)) return isolate->heap()->nan_value(); |
7098 return isolate->heap()->AllocateHeapNumber(result); | 7101 return isolate->heap()->AllocateHeapNumber(result); |
7099 } | 7102 } |
7100 | 7103 |
7101 // Fast version of Math.pow if we know that y is not an integer and y is not | 7104 // Fast version of Math.pow if we know that y is not an integer and y is not |
7102 // -0.5 or 0.5. Used as slow case from full codegen. | 7105 // -0.5 or 0.5. Used as slow case from full codegen. |
7103 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { | 7106 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { |
7104 NoHandleAllocation ha; | 7107 NoHandleAllocation ha(isolate); |
7105 ASSERT(args.length() == 2); | 7108 ASSERT(args.length() == 2); |
7106 isolate->counters()->math_pow()->Increment(); | 7109 isolate->counters()->math_pow()->Increment(); |
7107 | 7110 |
7108 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7111 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7109 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7112 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7110 if (y == 0) { | 7113 if (y == 0) { |
7111 return Smi::FromInt(1); | 7114 return Smi::FromInt(1); |
7112 } else { | 7115 } else { |
7113 double result = power_double_double(x, y); | 7116 double result = power_double_double(x, y); |
7114 if (isnan(result)) return isolate->heap()->nan_value(); | 7117 if (isnan(result)) return isolate->heap()->nan_value(); |
7115 return isolate->heap()->AllocateHeapNumber(result); | 7118 return isolate->heap()->AllocateHeapNumber(result); |
7116 } | 7119 } |
7117 } | 7120 } |
7118 | 7121 |
7119 | 7122 |
7120 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { | 7123 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { |
7121 NoHandleAllocation ha; | 7124 NoHandleAllocation ha(isolate); |
7122 ASSERT(args.length() == 1); | 7125 ASSERT(args.length() == 1); |
7123 isolate->counters()->math_round()->Increment(); | 7126 isolate->counters()->math_round()->Increment(); |
7124 | 7127 |
7125 if (!args[0]->IsHeapNumber()) { | 7128 if (!args[0]->IsHeapNumber()) { |
7126 // Must be smi. Return the argument unchanged for all the other types | 7129 // Must be smi. Return the argument unchanged for all the other types |
7127 // to make fuzz-natives test happy. | 7130 // to make fuzz-natives test happy. |
7128 return args[0]; | 7131 return args[0]; |
7129 } | 7132 } |
7130 | 7133 |
7131 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); | 7134 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); |
(...skipping 22 matching lines...) Expand all Loading... |
7154 } | 7157 } |
7155 | 7158 |
7156 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7159 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
7157 | 7160 |
7158 // Do not call NumberFromDouble() to avoid extra checks. | 7161 // Do not call NumberFromDouble() to avoid extra checks. |
7159 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); | 7162 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); |
7160 } | 7163 } |
7161 | 7164 |
7162 | 7165 |
7163 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { | 7166 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { |
7164 NoHandleAllocation ha; | 7167 NoHandleAllocation ha(isolate); |
7165 ASSERT(args.length() == 1); | 7168 ASSERT(args.length() == 1); |
7166 isolate->counters()->math_sin()->Increment(); | 7169 isolate->counters()->math_sin()->Increment(); |
7167 | 7170 |
7168 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7171 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7169 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); | 7172 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); |
7170 } | 7173 } |
7171 | 7174 |
7172 | 7175 |
7173 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { | 7176 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { |
7174 NoHandleAllocation ha; | 7177 NoHandleAllocation ha(isolate); |
7175 ASSERT(args.length() == 1); | 7178 ASSERT(args.length() == 1); |
7176 isolate->counters()->math_sqrt()->Increment(); | 7179 isolate->counters()->math_sqrt()->Increment(); |
7177 | 7180 |
7178 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7181 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7179 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); | 7182 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); |
7180 } | 7183 } |
7181 | 7184 |
7182 | 7185 |
7183 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { | 7186 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { |
7184 NoHandleAllocation ha; | 7187 NoHandleAllocation ha(isolate); |
7185 ASSERT(args.length() == 1); | 7188 ASSERT(args.length() == 1); |
7186 isolate->counters()->math_tan()->Increment(); | 7189 isolate->counters()->math_tan()->Increment(); |
7187 | 7190 |
7188 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7191 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7189 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); | 7192 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); |
7190 } | 7193 } |
7191 | 7194 |
7192 | 7195 |
7193 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7196 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
7194 NoHandleAllocation ha; | 7197 NoHandleAllocation ha(isolate); |
7195 ASSERT(args.length() == 2); | 7198 ASSERT(args.length() == 2); |
7196 | 7199 |
7197 CONVERT_SMI_ARG_CHECKED(year, 0); | 7200 CONVERT_SMI_ARG_CHECKED(year, 0); |
7198 CONVERT_SMI_ARG_CHECKED(month, 1); | 7201 CONVERT_SMI_ARG_CHECKED(month, 1); |
7199 | 7202 |
7200 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7203 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
7201 } | 7204 } |
7202 | 7205 |
7203 | 7206 |
7204 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { | 7207 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7327 for (int i = 0; i < argument_count; ++i) { | 7330 for (int i = 0; i < argument_count; ++i) { |
7328 elements->set(i, *(parameters - i - 1)); | 7331 elements->set(i, *(parameters - i - 1)); |
7329 } | 7332 } |
7330 } | 7333 } |
7331 } | 7334 } |
7332 return *result; | 7335 return *result; |
7333 } | 7336 } |
7334 | 7337 |
7335 | 7338 |
7336 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) { | 7339 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) { |
7337 NoHandleAllocation ha; | 7340 NoHandleAllocation ha(isolate); |
7338 ASSERT(args.length() == 3); | 7341 ASSERT(args.length() == 3); |
7339 | 7342 |
7340 JSFunction* callee = JSFunction::cast(args[0]); | 7343 JSFunction* callee = JSFunction::cast(args[0]); |
7341 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7344 Object** parameters = reinterpret_cast<Object**>(args[1]); |
7342 const int length = args.smi_at(2); | 7345 const int length = args.smi_at(2); |
7343 | 7346 |
7344 Object* result; | 7347 Object* result; |
7345 { MaybeObject* maybe_result = | 7348 { MaybeObject* maybe_result = |
7346 isolate->heap()->AllocateArgumentsObject(callee, length); | 7349 isolate->heap()->AllocateArgumentsObject(callee, length); |
7347 if (!maybe_result->ToObject(&result)) return maybe_result; | 7350 if (!maybe_result->ToObject(&result)) return maybe_result; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7407 frame, | 7410 frame, |
7408 inlined_jsframe_index, | 7411 inlined_jsframe_index, |
7409 inlined_function->shared()->formal_parameter_count()); | 7412 inlined_function->shared()->formal_parameter_count()); |
7410 | 7413 |
7411 int args_count = args_slots.length(); | 7414 int args_count = args_slots.length(); |
7412 | 7415 |
7413 *total_argc = prefix_argc + args_count; | 7416 *total_argc = prefix_argc + args_count; |
7414 SmartArrayPointer<Handle<Object> > param_data( | 7417 SmartArrayPointer<Handle<Object> > param_data( |
7415 NewArray<Handle<Object> >(*total_argc)); | 7418 NewArray<Handle<Object> >(*total_argc)); |
7416 for (int i = 0; i < args_count; i++) { | 7419 for (int i = 0; i < args_count; i++) { |
7417 Handle<Object> val = args_slots[i].GetValue(); | 7420 Handle<Object> val = args_slots[i].GetValue(isolate); |
7418 param_data[prefix_argc + i] = val; | 7421 param_data[prefix_argc + i] = val; |
7419 } | 7422 } |
7420 | 7423 |
7421 args_slots.Dispose(); | 7424 args_slots.Dispose(); |
7422 | 7425 |
7423 return param_data; | 7426 return param_data; |
7424 } else { | 7427 } else { |
7425 it.AdvanceToArgumentsFrame(); | 7428 it.AdvanceToArgumentsFrame(); |
7426 frame = it.frame(); | 7429 frame = it.frame(); |
7427 int args_count = frame->ComputeParametersCount(); | 7430 int args_count = frame->ComputeParametersCount(); |
7428 | 7431 |
7429 *total_argc = prefix_argc + args_count; | 7432 *total_argc = prefix_argc + args_count; |
7430 SmartArrayPointer<Handle<Object> > param_data( | 7433 SmartArrayPointer<Handle<Object> > param_data( |
7431 NewArray<Handle<Object> >(*total_argc)); | 7434 NewArray<Handle<Object> >(*total_argc)); |
7432 for (int i = 0; i < args_count; i++) { | 7435 for (int i = 0; i < args_count; i++) { |
7433 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); | 7436 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); |
7434 param_data[prefix_argc + i] = val; | 7437 param_data[prefix_argc + i] = val; |
7435 } | 7438 } |
7436 return param_data; | 7439 return param_data; |
7437 } | 7440 } |
7438 } | 7441 } |
7439 | 7442 |
7440 | 7443 |
7441 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { | 7444 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { |
7442 HandleScope scope(isolate); | 7445 HandleScope scope(isolate); |
7443 ASSERT(args.length() == 4); | 7446 ASSERT(args.length() == 4); |
(...skipping 16 matching lines...) Expand all Loading... |
7460 } | 7463 } |
7461 // Initialize array of bindings (function, this, and any existing arguments | 7464 // Initialize array of bindings (function, this, and any existing arguments |
7462 // if the function was already bound). | 7465 // if the function was already bound). |
7463 Handle<FixedArray> new_bindings; | 7466 Handle<FixedArray> new_bindings; |
7464 int i; | 7467 int i; |
7465 if (bindee->IsJSFunction() && JSFunction::cast(*bindee)->shared()->bound()) { | 7468 if (bindee->IsJSFunction() && JSFunction::cast(*bindee)->shared()->bound()) { |
7466 Handle<FixedArray> old_bindings( | 7469 Handle<FixedArray> old_bindings( |
7467 JSFunction::cast(*bindee)->function_bindings()); | 7470 JSFunction::cast(*bindee)->function_bindings()); |
7468 new_bindings = | 7471 new_bindings = |
7469 isolate->factory()->NewFixedArray(old_bindings->length() + argc); | 7472 isolate->factory()->NewFixedArray(old_bindings->length() + argc); |
7470 bindee = Handle<Object>(old_bindings->get(JSFunction::kBoundFunctionIndex)); | 7473 bindee = Handle<Object>(old_bindings->get(JSFunction::kBoundFunctionIndex), |
| 7474 isolate); |
7471 i = 0; | 7475 i = 0; |
7472 for (int n = old_bindings->length(); i < n; i++) { | 7476 for (int n = old_bindings->length(); i < n; i++) { |
7473 new_bindings->set(i, old_bindings->get(i)); | 7477 new_bindings->set(i, old_bindings->get(i)); |
7474 } | 7478 } |
7475 } else { | 7479 } else { |
7476 int array_size = JSFunction::kBoundArgumentsStartIndex + argc; | 7480 int array_size = JSFunction::kBoundArgumentsStartIndex + argc; |
7477 new_bindings = isolate->factory()->NewFixedArray(array_size); | 7481 new_bindings = isolate->factory()->NewFixedArray(array_size); |
7478 new_bindings->set(JSFunction::kBoundFunctionIndex, *bindee); | 7482 new_bindings->set(JSFunction::kBoundFunctionIndex, *bindee); |
7479 new_bindings->set(JSFunction::kBoundThisIndex, args[2]); | 7483 new_bindings->set(JSFunction::kBoundThisIndex, args[2]); |
7480 i = 2; | 7484 i = 2; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7519 // First argument is a function to use as a constructor. | 7523 // First argument is a function to use as a constructor. |
7520 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 7524 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
7521 RUNTIME_ASSERT(function->shared()->bound()); | 7525 RUNTIME_ASSERT(function->shared()->bound()); |
7522 | 7526 |
7523 // The argument is a bound function. Extract its bound arguments | 7527 // The argument is a bound function. Extract its bound arguments |
7524 // and callable. | 7528 // and callable. |
7525 Handle<FixedArray> bound_args = | 7529 Handle<FixedArray> bound_args = |
7526 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); | 7530 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); |
7527 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; | 7531 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; |
7528 Handle<Object> bound_function( | 7532 Handle<Object> bound_function( |
7529 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex))); | 7533 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)), |
| 7534 isolate); |
7530 ASSERT(!bound_function->IsJSFunction() || | 7535 ASSERT(!bound_function->IsJSFunction() || |
7531 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); | 7536 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); |
7532 | 7537 |
7533 int total_argc = 0; | 7538 int total_argc = 0; |
7534 SmartArrayPointer<Handle<Object> > param_data = | 7539 SmartArrayPointer<Handle<Object> > param_data = |
7535 GetCallerArguments(isolate, bound_argc, &total_argc); | 7540 GetCallerArguments(isolate, bound_argc, &total_argc); |
7536 for (int i = 0; i < bound_argc; i++) { | 7541 for (int i = 0; i < bound_argc; i++) { |
7537 param_data[i] = Handle<Object>(bound_args->get( | 7542 param_data[i] = Handle<Object>(bound_args->get( |
7538 JSFunction::kBoundArgumentsStartIndex + i)); | 7543 JSFunction::kBoundArgumentsStartIndex + i), isolate); |
7539 } | 7544 } |
7540 | 7545 |
7541 if (!bound_function->IsJSFunction()) { | 7546 if (!bound_function->IsJSFunction()) { |
7542 bool exception_thrown; | 7547 bool exception_thrown; |
7543 bound_function = Execution::TryGetConstructorDelegate(bound_function, | 7548 bound_function = Execution::TryGetConstructorDelegate(bound_function, |
7544 &exception_thrown); | 7549 &exception_thrown); |
7545 if (exception_thrown) return Failure::Exception(); | 7550 if (exception_thrown) return Failure::Exception(); |
7546 } | 7551 } |
7547 ASSERT(bound_function->IsJSFunction()); | 7552 ASSERT(bound_function->IsJSFunction()); |
7548 | 7553 |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8102 if (argc > argv_small_size) { | 8107 if (argc > argv_small_size) { |
8103 argv = new Handle<Object>[argc]; | 8108 argv = new Handle<Object>[argc]; |
8104 if (argv == NULL) return isolate->StackOverflow(); | 8109 if (argv == NULL) return isolate->StackOverflow(); |
8105 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); | 8110 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); |
8106 } | 8111 } |
8107 | 8112 |
8108 for (int i = 0; i < argc; ++i) { | 8113 for (int i = 0; i < argc; ++i) { |
8109 MaybeObject* maybe = args[1 + i]; | 8114 MaybeObject* maybe = args[1 + i]; |
8110 Object* object; | 8115 Object* object; |
8111 if (!maybe->To<Object>(&object)) return maybe; | 8116 if (!maybe->To<Object>(&object)) return maybe; |
8112 argv[i] = Handle<Object>(object); | 8117 argv[i] = Handle<Object>(object, isolate); |
8113 } | 8118 } |
8114 | 8119 |
8115 bool threw; | 8120 bool threw; |
8116 Handle<JSReceiver> hfun(fun); | 8121 Handle<JSReceiver> hfun(fun); |
8117 Handle<Object> hreceiver(receiver); | 8122 Handle<Object> hreceiver(receiver, isolate); |
8118 Handle<Object> result = | 8123 Handle<Object> result = |
8119 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); | 8124 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); |
8120 | 8125 |
8121 if (threw) return Failure::Exception(); | 8126 if (threw) return Failure::Exception(); |
8122 return *result; | 8127 return *result; |
8123 } | 8128 } |
8124 | 8129 |
8125 | 8130 |
8126 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { | 8131 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { |
8127 HandleScope scope(isolate); | 8132 HandleScope scope(isolate); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8168 | 8173 |
8169 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 8174 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { |
8170 HandleScope scope(isolate); | 8175 HandleScope scope(isolate); |
8171 ASSERT(args.length() == 1); | 8176 ASSERT(args.length() == 1); |
8172 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 8177 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
8173 return *Execution::GetConstructorDelegate(args.at<Object>(0)); | 8178 return *Execution::GetConstructorDelegate(args.at<Object>(0)); |
8174 } | 8179 } |
8175 | 8180 |
8176 | 8181 |
8177 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { | 8182 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { |
8178 NoHandleAllocation ha; | 8183 NoHandleAllocation ha(isolate); |
8179 ASSERT(args.length() == 2); | 8184 ASSERT(args.length() == 2); |
8180 | 8185 |
8181 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8186 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
8182 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); | 8187 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); |
8183 Context* result; | 8188 Context* result; |
8184 MaybeObject* maybe_result = | 8189 MaybeObject* maybe_result = |
8185 isolate->heap()->AllocateGlobalContext(function, scope_info); | 8190 isolate->heap()->AllocateGlobalContext(function, scope_info); |
8186 if (!maybe_result->To(&result)) return maybe_result; | 8191 if (!maybe_result->To(&result)) return maybe_result; |
8187 | 8192 |
8188 ASSERT(function->context() == isolate->context()); | 8193 ASSERT(function->context() == isolate->context()); |
8189 ASSERT(function->context()->global_object() == result->global_object()); | 8194 ASSERT(function->context()->global_object() == result->global_object()); |
8190 isolate->set_context(result); | 8195 isolate->set_context(result); |
8191 result->global_object()->set_global_context(result); | 8196 result->global_object()->set_global_context(result); |
8192 | 8197 |
8193 return result; // non-failure | 8198 return result; // non-failure |
8194 } | 8199 } |
8195 | 8200 |
8196 | 8201 |
8197 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { | 8202 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { |
8198 NoHandleAllocation ha; | 8203 NoHandleAllocation ha(isolate); |
8199 ASSERT(args.length() == 1); | 8204 ASSERT(args.length() == 1); |
8200 | 8205 |
8201 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8206 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
8202 int length = function->shared()->scope_info()->ContextLength(); | 8207 int length = function->shared()->scope_info()->ContextLength(); |
8203 Context* result; | 8208 Context* result; |
8204 MaybeObject* maybe_result = | 8209 MaybeObject* maybe_result = |
8205 isolate->heap()->AllocateFunctionContext(length, function); | 8210 isolate->heap()->AllocateFunctionContext(length, function); |
8206 if (!maybe_result->To(&result)) return maybe_result; | 8211 if (!maybe_result->To(&result)) return maybe_result; |
8207 | 8212 |
8208 isolate->set_context(result); | 8213 isolate->set_context(result); |
8209 | 8214 |
8210 return result; // non-failure | 8215 return result; // non-failure |
8211 } | 8216 } |
8212 | 8217 |
8213 | 8218 |
8214 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { | 8219 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { |
8215 NoHandleAllocation ha; | 8220 NoHandleAllocation ha(isolate); |
8216 ASSERT(args.length() == 2); | 8221 ASSERT(args.length() == 2); |
8217 JSObject* extension_object; | 8222 JSObject* extension_object; |
8218 if (args[0]->IsJSObject()) { | 8223 if (args[0]->IsJSObject()) { |
8219 extension_object = JSObject::cast(args[0]); | 8224 extension_object = JSObject::cast(args[0]); |
8220 } else { | 8225 } else { |
8221 // Convert the object to a proper JavaScript object. | 8226 // Convert the object to a proper JavaScript object. |
8222 MaybeObject* maybe_js_object = args[0]->ToObject(); | 8227 MaybeObject* maybe_js_object = args[0]->ToObject(); |
8223 if (!maybe_js_object->To(&extension_object)) { | 8228 if (!maybe_js_object->To(&extension_object)) { |
8224 if (Failure::cast(maybe_js_object)->IsInternalError()) { | 8229 if (Failure::cast(maybe_js_object)->IsInternalError()) { |
8225 HandleScope scope(isolate); | 8230 HandleScope scope(isolate); |
(...skipping 23 matching lines...) Expand all Loading... |
8249 isolate->heap()->AllocateWithContext(function, | 8254 isolate->heap()->AllocateWithContext(function, |
8250 isolate->context(), | 8255 isolate->context(), |
8251 extension_object); | 8256 extension_object); |
8252 if (!maybe_context->To(&context)) return maybe_context; | 8257 if (!maybe_context->To(&context)) return maybe_context; |
8253 isolate->set_context(context); | 8258 isolate->set_context(context); |
8254 return context; | 8259 return context; |
8255 } | 8260 } |
8256 | 8261 |
8257 | 8262 |
8258 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { | 8263 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { |
8259 NoHandleAllocation ha; | 8264 NoHandleAllocation ha(isolate); |
8260 ASSERT(args.length() == 3); | 8265 ASSERT(args.length() == 3); |
8261 String* name = String::cast(args[0]); | 8266 String* name = String::cast(args[0]); |
8262 Object* thrown_object = args[1]; | 8267 Object* thrown_object = args[1]; |
8263 JSFunction* function; | 8268 JSFunction* function; |
8264 if (args[2]->IsSmi()) { | 8269 if (args[2]->IsSmi()) { |
8265 // A smi sentinel indicates a context nested inside global code rather | 8270 // A smi sentinel indicates a context nested inside global code rather |
8266 // than some function. There is a canonical empty function that can be | 8271 // than some function. There is a canonical empty function that can be |
8267 // gotten from the native context. | 8272 // gotten from the native context. |
8268 function = isolate->context()->native_context()->closure(); | 8273 function = isolate->context()->native_context()->closure(); |
8269 } else { | 8274 } else { |
8270 function = JSFunction::cast(args[2]); | 8275 function = JSFunction::cast(args[2]); |
8271 } | 8276 } |
8272 Context* context; | 8277 Context* context; |
8273 MaybeObject* maybe_context = | 8278 MaybeObject* maybe_context = |
8274 isolate->heap()->AllocateCatchContext(function, | 8279 isolate->heap()->AllocateCatchContext(function, |
8275 isolate->context(), | 8280 isolate->context(), |
8276 name, | 8281 name, |
8277 thrown_object); | 8282 thrown_object); |
8278 if (!maybe_context->To(&context)) return maybe_context; | 8283 if (!maybe_context->To(&context)) return maybe_context; |
8279 isolate->set_context(context); | 8284 isolate->set_context(context); |
8280 return context; | 8285 return context; |
8281 } | 8286 } |
8282 | 8287 |
8283 | 8288 |
8284 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { | 8289 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { |
8285 NoHandleAllocation ha; | 8290 NoHandleAllocation ha(isolate); |
8286 ASSERT(args.length() == 2); | 8291 ASSERT(args.length() == 2); |
8287 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); | 8292 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); |
8288 JSFunction* function; | 8293 JSFunction* function; |
8289 if (args[1]->IsSmi()) { | 8294 if (args[1]->IsSmi()) { |
8290 // A smi sentinel indicates a context nested inside global code rather | 8295 // A smi sentinel indicates a context nested inside global code rather |
8291 // than some function. There is a canonical empty function that can be | 8296 // than some function. There is a canonical empty function that can be |
8292 // gotten from the native context. | 8297 // gotten from the native context. |
8293 function = isolate->context()->native_context()->closure(); | 8298 function = isolate->context()->native_context()->closure(); |
8294 } else { | 8299 } else { |
8295 function = JSFunction::cast(args[1]); | 8300 function = JSFunction::cast(args[1]); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8550 } | 8555 } |
8551 } | 8556 } |
8552 | 8557 |
8553 // Otherwise, if the slot was found the holder is a context extension | 8558 // Otherwise, if the slot was found the holder is a context extension |
8554 // object, subject of a with, or a global object. We read the named | 8559 // object, subject of a with, or a global object. We read the named |
8555 // property from it. | 8560 // property from it. |
8556 if (!holder.is_null()) { | 8561 if (!holder.is_null()) { |
8557 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 8562 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
8558 ASSERT(object->HasProperty(*name)); | 8563 ASSERT(object->HasProperty(*name)); |
8559 // GetProperty below can cause GC. | 8564 // GetProperty below can cause GC. |
8560 Handle<Object> receiver_handle(object->IsGlobalObject() | 8565 Handle<Object> receiver_handle( |
8561 ? GlobalObject::cast(*object)->global_receiver() | 8566 object->IsGlobalObject() |
8562 : ComputeReceiverForNonGlobal(isolate, *object)); | 8567 ? GlobalObject::cast(*object)->global_receiver() |
| 8568 : ComputeReceiverForNonGlobal(isolate, *object), |
| 8569 isolate); |
8563 | 8570 |
8564 // No need to unhole the value here. This is taken care of by the | 8571 // No need to unhole the value here. This is taken care of by the |
8565 // GetProperty function. | 8572 // GetProperty function. |
8566 MaybeObject* value = object->GetProperty(*name); | 8573 MaybeObject* value = object->GetProperty(*name); |
8567 return MakePair(value, *receiver_handle); | 8574 return MakePair(value, *receiver_handle); |
8568 } | 8575 } |
8569 | 8576 |
8570 if (throw_error) { | 8577 if (throw_error) { |
8571 // The property doesn't exist - throw exception. | 8578 // The property doesn't exist - throw exception. |
8572 Handle<Object> reference_error = | 8579 Handle<Object> reference_error = |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8718 "not_date_object", HandleVector<Object>(NULL, 0))); | 8725 "not_date_object", HandleVector<Object>(NULL, 0))); |
8719 } | 8726 } |
8720 | 8727 |
8721 | 8728 |
8722 | 8729 |
8723 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { | 8730 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { |
8724 ASSERT(args.length() == 0); | 8731 ASSERT(args.length() == 0); |
8725 | 8732 |
8726 // First check if this is a real stack overflow. | 8733 // First check if this is a real stack overflow. |
8727 if (isolate->stack_guard()->IsStackOverflow()) { | 8734 if (isolate->stack_guard()->IsStackOverflow()) { |
8728 NoHandleAllocation na; | 8735 NoHandleAllocation na(isolate); |
8729 return isolate->StackOverflow(); | 8736 return isolate->StackOverflow(); |
8730 } | 8737 } |
8731 | 8738 |
8732 return Execution::HandleStackGuardInterrupt(isolate); | 8739 return Execution::HandleStackGuardInterrupt(isolate); |
8733 } | 8740 } |
8734 | 8741 |
8735 | 8742 |
8736 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { | 8743 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { |
8737 ASSERT(args.length() == 0); | 8744 ASSERT(args.length() == 0); |
8738 return Execution::HandleStackGuardInterrupt(isolate); | 8745 return Execution::HandleStackGuardInterrupt(isolate); |
(...skipping 24 matching lines...) Expand all Loading... |
8763 // function result | 8770 // function result |
8764 PrintF("} -> "); | 8771 PrintF("} -> "); |
8765 result->ShortPrint(); | 8772 result->ShortPrint(); |
8766 PrintF("\n"); | 8773 PrintF("\n"); |
8767 } | 8774 } |
8768 } | 8775 } |
8769 | 8776 |
8770 | 8777 |
8771 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { | 8778 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { |
8772 ASSERT(args.length() == 0); | 8779 ASSERT(args.length() == 0); |
8773 NoHandleAllocation ha; | 8780 NoHandleAllocation ha(isolate); |
8774 PrintTransition(isolate, NULL); | 8781 PrintTransition(isolate, NULL); |
8775 return isolate->heap()->undefined_value(); | 8782 return isolate->heap()->undefined_value(); |
8776 } | 8783 } |
8777 | 8784 |
8778 | 8785 |
8779 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { | 8786 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { |
8780 NoHandleAllocation ha; | 8787 NoHandleAllocation ha(isolate); |
8781 PrintTransition(isolate, args[0]); | 8788 PrintTransition(isolate, args[0]); |
8782 return args[0]; // return TOS | 8789 return args[0]; // return TOS |
8783 } | 8790 } |
8784 | 8791 |
8785 | 8792 |
8786 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { | 8793 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { |
8787 NoHandleAllocation ha; | 8794 NoHandleAllocation ha(isolate); |
8788 ASSERT(args.length() == 1); | 8795 ASSERT(args.length() == 1); |
8789 | 8796 |
8790 #ifdef DEBUG | 8797 #ifdef DEBUG |
8791 if (args[0]->IsString()) { | 8798 if (args[0]->IsString()) { |
8792 // If we have a string, assume it's a code "marker" | 8799 // If we have a string, assume it's a code "marker" |
8793 // and print some interesting cpu debugging info. | 8800 // and print some interesting cpu debugging info. |
8794 JavaScriptFrameIterator it(isolate); | 8801 JavaScriptFrameIterator it(isolate); |
8795 JavaScriptFrame* frame = it.frame(); | 8802 JavaScriptFrame* frame = it.frame(); |
8796 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 8803 PrintF("fp = %p, sp = %p, caller_sp = %p: ", |
8797 frame->fp(), frame->sp(), frame->caller_sp()); | 8804 frame->fp(), frame->sp(), frame->caller_sp()); |
(...skipping 11 matching lines...) Expand all Loading... |
8809 #endif | 8816 #endif |
8810 PrintF("\n"); | 8817 PrintF("\n"); |
8811 Flush(); | 8818 Flush(); |
8812 | 8819 |
8813 return args[0]; // return TOS | 8820 return args[0]; // return TOS |
8814 } | 8821 } |
8815 | 8822 |
8816 | 8823 |
8817 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { | 8824 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { |
8818 ASSERT(args.length() == 0); | 8825 ASSERT(args.length() == 0); |
8819 NoHandleAllocation ha; | 8826 NoHandleAllocation ha(isolate); |
8820 isolate->PrintStack(); | 8827 isolate->PrintStack(); |
8821 return isolate->heap()->undefined_value(); | 8828 return isolate->heap()->undefined_value(); |
8822 } | 8829 } |
8823 | 8830 |
8824 | 8831 |
8825 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 8832 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { |
8826 NoHandleAllocation ha; | 8833 NoHandleAllocation ha(isolate); |
8827 ASSERT(args.length() == 0); | 8834 ASSERT(args.length() == 0); |
8828 | 8835 |
8829 // According to ECMA-262, section 15.9.1, page 117, the precision of | 8836 // According to ECMA-262, section 15.9.1, page 117, the precision of |
8830 // the number in a Date object representing a particular instant in | 8837 // the number in a Date object representing a particular instant in |
8831 // time is milliseconds. Therefore, we floor the result of getting | 8838 // time is milliseconds. Therefore, we floor the result of getting |
8832 // the OS time. | 8839 // the OS time. |
8833 double millis = floor(OS::TimeCurrentMillis()); | 8840 double millis = floor(OS::TimeCurrentMillis()); |
8834 return isolate->heap()->NumberFromDouble(millis); | 8841 return isolate->heap()->NumberFromDouble(millis); |
8835 } | 8842 } |
8836 | 8843 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8868 | 8875 |
8869 if (result) { | 8876 if (result) { |
8870 return *output; | 8877 return *output; |
8871 } else { | 8878 } else { |
8872 return isolate->heap()->null_value(); | 8879 return isolate->heap()->null_value(); |
8873 } | 8880 } |
8874 } | 8881 } |
8875 | 8882 |
8876 | 8883 |
8877 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 8884 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
8878 NoHandleAllocation ha; | 8885 NoHandleAllocation ha(isolate); |
8879 ASSERT(args.length() == 1); | 8886 ASSERT(args.length() == 1); |
8880 | 8887 |
8881 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 8888 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
8882 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); | 8889 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); |
8883 const char* zone = OS::LocalTimezone(static_cast<double>(time)); | 8890 const char* zone = OS::LocalTimezone(static_cast<double>(time)); |
8884 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); | 8891 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); |
8885 } | 8892 } |
8886 | 8893 |
8887 | 8894 |
8888 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 8895 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
8889 NoHandleAllocation ha; | 8896 NoHandleAllocation ha(isolate); |
8890 ASSERT(args.length() == 1); | 8897 ASSERT(args.length() == 1); |
8891 | 8898 |
8892 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 8899 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
8893 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 8900 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
8894 | 8901 |
8895 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); | 8902 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); |
8896 } | 8903 } |
8897 | 8904 |
8898 | 8905 |
8899 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 8906 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9184 // Convert storage to dictionary mode. | 9191 // Convert storage to dictionary mode. |
9185 void SetDictionaryMode(uint32_t index) { | 9192 void SetDictionaryMode(uint32_t index) { |
9186 ASSERT(fast_elements_); | 9193 ASSERT(fast_elements_); |
9187 Handle<FixedArray> current_storage(*storage_); | 9194 Handle<FixedArray> current_storage(*storage_); |
9188 Handle<SeededNumberDictionary> slow_storage( | 9195 Handle<SeededNumberDictionary> slow_storage( |
9189 isolate_->factory()->NewSeededNumberDictionary( | 9196 isolate_->factory()->NewSeededNumberDictionary( |
9190 current_storage->length())); | 9197 current_storage->length())); |
9191 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); | 9198 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); |
9192 for (uint32_t i = 0; i < current_length; i++) { | 9199 for (uint32_t i = 0; i < current_length; i++) { |
9193 HandleScope loop_scope(isolate_); | 9200 HandleScope loop_scope(isolate_); |
9194 Handle<Object> element(current_storage->get(i)); | 9201 Handle<Object> element(current_storage->get(i), isolate_); |
9195 if (!element->IsTheHole()) { | 9202 if (!element->IsTheHole()) { |
9196 Handle<SeededNumberDictionary> new_storage = | 9203 Handle<SeededNumberDictionary> new_storage = |
9197 isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element); | 9204 isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element); |
9198 if (!new_storage.is_identical_to(slow_storage)) { | 9205 if (!new_storage.is_identical_to(slow_storage)) { |
9199 slow_storage = loop_scope.CloseAndEscape(new_storage); | 9206 slow_storage = loop_scope.CloseAndEscape(new_storage); |
9200 } | 9207 } |
9201 } | 9208 } |
9202 } | 9209 } |
9203 clear_storage(); | 9210 clear_storage(); |
9204 set_storage(*slow_storage); | 9211 set_storage(*slow_storage); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9257 for (int i = 0; i < fast_length; i++) { | 9264 for (int i = 0; i < fast_length; i++) { |
9258 if (!elements->is_the_hole(i)) element_count++; | 9265 if (!elements->is_the_hole(i)) element_count++; |
9259 } | 9266 } |
9260 break; | 9267 break; |
9261 } | 9268 } |
9262 case DICTIONARY_ELEMENTS: { | 9269 case DICTIONARY_ELEMENTS: { |
9263 Handle<SeededNumberDictionary> dictionary( | 9270 Handle<SeededNumberDictionary> dictionary( |
9264 SeededNumberDictionary::cast(array->elements())); | 9271 SeededNumberDictionary::cast(array->elements())); |
9265 int capacity = dictionary->Capacity(); | 9272 int capacity = dictionary->Capacity(); |
9266 for (int i = 0; i < capacity; i++) { | 9273 for (int i = 0; i < capacity; i++) { |
9267 Handle<Object> key(dictionary->KeyAt(i)); | 9274 Handle<Object> key(dictionary->KeyAt(i), array->GetIsolate()); |
9268 if (dictionary->IsKey(*key)) { | 9275 if (dictionary->IsKey(*key)) { |
9269 element_count++; | 9276 element_count++; |
9270 } | 9277 } |
9271 } | 9278 } |
9272 break; | 9279 break; |
9273 } | 9280 } |
9274 case NON_STRICT_ARGUMENTS_ELEMENTS: | 9281 case NON_STRICT_ARGUMENTS_ELEMENTS: |
9275 case EXTERNAL_BYTE_ELEMENTS: | 9282 case EXTERNAL_BYTE_ELEMENTS: |
9276 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 9283 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
9277 case EXTERNAL_SHORT_ELEMENTS: | 9284 case EXTERNAL_SHORT_ELEMENTS: |
(...skipping 21 matching lines...) Expand all Loading... |
9299 ArrayConcatVisitor* visitor) { | 9306 ArrayConcatVisitor* visitor) { |
9300 Handle<ExternalArrayClass> array( | 9307 Handle<ExternalArrayClass> array( |
9301 ExternalArrayClass::cast(receiver->elements())); | 9308 ExternalArrayClass::cast(receiver->elements())); |
9302 uint32_t len = static_cast<uint32_t>(array->length()); | 9309 uint32_t len = static_cast<uint32_t>(array->length()); |
9303 | 9310 |
9304 ASSERT(visitor != NULL); | 9311 ASSERT(visitor != NULL); |
9305 if (elements_are_ints) { | 9312 if (elements_are_ints) { |
9306 if (elements_are_guaranteed_smis) { | 9313 if (elements_are_guaranteed_smis) { |
9307 for (uint32_t j = 0; j < len; j++) { | 9314 for (uint32_t j = 0; j < len; j++) { |
9308 HandleScope loop_scope(isolate); | 9315 HandleScope loop_scope(isolate); |
9309 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j)))); | 9316 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))), |
| 9317 isolate); |
9310 visitor->visit(j, e); | 9318 visitor->visit(j, e); |
9311 } | 9319 } |
9312 } else { | 9320 } else { |
9313 for (uint32_t j = 0; j < len; j++) { | 9321 for (uint32_t j = 0; j < len; j++) { |
9314 HandleScope loop_scope(isolate); | 9322 HandleScope loop_scope(isolate); |
9315 int64_t val = static_cast<int64_t>(array->get_scalar(j)); | 9323 int64_t val = static_cast<int64_t>(array->get_scalar(j)); |
9316 if (Smi::IsValid(static_cast<intptr_t>(val))) { | 9324 if (Smi::IsValid(static_cast<intptr_t>(val))) { |
9317 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); | 9325 Handle<Smi> e(Smi::FromInt(static_cast<int>(val)), isolate); |
9318 visitor->visit(j, e); | 9326 visitor->visit(j, e); |
9319 } else { | 9327 } else { |
9320 Handle<Object> e = | 9328 Handle<Object> e = |
9321 isolate->factory()->NewNumber(static_cast<ElementType>(val)); | 9329 isolate->factory()->NewNumber(static_cast<ElementType>(val)); |
9322 visitor->visit(j, e); | 9330 visitor->visit(j, e); |
9323 } | 9331 } |
9324 } | 9332 } |
9325 } | 9333 } |
9326 } else { | 9334 } else { |
9327 for (uint32_t j = 0; j < len; j++) { | 9335 for (uint32_t j = 0; j < len; j++) { |
9328 HandleScope loop_scope(isolate); | 9336 HandleScope loop_scope(isolate); |
9329 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); | 9337 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); |
9330 visitor->visit(j, e); | 9338 visitor->visit(j, e); |
9331 } | 9339 } |
9332 } | 9340 } |
9333 } | 9341 } |
9334 | 9342 |
9335 | 9343 |
9336 // Used for sorting indices in a List<uint32_t>. | 9344 // Used for sorting indices in a List<uint32_t>. |
9337 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { | 9345 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { |
9338 uint32_t a = *ap; | 9346 uint32_t a = *ap; |
9339 uint32_t b = *bp; | 9347 uint32_t b = *bp; |
9340 return (a == b) ? 0 : (a < b) ? -1 : 1; | 9348 return (a == b) ? 0 : (a < b) ? -1 : 1; |
9341 } | 9349 } |
9342 | 9350 |
9343 | 9351 |
9344 static void CollectElementIndices(Handle<JSObject> object, | 9352 static void CollectElementIndices(Handle<JSObject> object, |
9345 uint32_t range, | 9353 uint32_t range, |
9346 List<uint32_t>* indices) { | 9354 List<uint32_t>* indices) { |
| 9355 Isolate* isolate = object->GetIsolate(); |
9347 ElementsKind kind = object->GetElementsKind(); | 9356 ElementsKind kind = object->GetElementsKind(); |
9348 switch (kind) { | 9357 switch (kind) { |
9349 case FAST_SMI_ELEMENTS: | 9358 case FAST_SMI_ELEMENTS: |
9350 case FAST_ELEMENTS: | 9359 case FAST_ELEMENTS: |
9351 case FAST_HOLEY_SMI_ELEMENTS: | 9360 case FAST_HOLEY_SMI_ELEMENTS: |
9352 case FAST_HOLEY_ELEMENTS: { | 9361 case FAST_HOLEY_ELEMENTS: { |
9353 Handle<FixedArray> elements(FixedArray::cast(object->elements())); | 9362 Handle<FixedArray> elements(FixedArray::cast(object->elements())); |
9354 uint32_t length = static_cast<uint32_t>(elements->length()); | 9363 uint32_t length = static_cast<uint32_t>(elements->length()); |
9355 if (range < length) length = range; | 9364 if (range < length) length = range; |
9356 for (uint32_t i = 0; i < length; i++) { | 9365 for (uint32_t i = 0; i < length; i++) { |
9357 if (!elements->get(i)->IsTheHole()) { | 9366 if (!elements->get(i)->IsTheHole()) { |
9358 indices->Add(i); | 9367 indices->Add(i); |
9359 } | 9368 } |
9360 } | 9369 } |
9361 break; | 9370 break; |
9362 } | 9371 } |
9363 case FAST_HOLEY_DOUBLE_ELEMENTS: | 9372 case FAST_HOLEY_DOUBLE_ELEMENTS: |
9364 case FAST_DOUBLE_ELEMENTS: { | 9373 case FAST_DOUBLE_ELEMENTS: { |
9365 // TODO(1810): Decide if it's worthwhile to implement this. | 9374 // TODO(1810): Decide if it's worthwhile to implement this. |
9366 UNREACHABLE(); | 9375 UNREACHABLE(); |
9367 break; | 9376 break; |
9368 } | 9377 } |
9369 case DICTIONARY_ELEMENTS: { | 9378 case DICTIONARY_ELEMENTS: { |
9370 Handle<SeededNumberDictionary> dict( | 9379 Handle<SeededNumberDictionary> dict( |
9371 SeededNumberDictionary::cast(object->elements())); | 9380 SeededNumberDictionary::cast(object->elements())); |
9372 uint32_t capacity = dict->Capacity(); | 9381 uint32_t capacity = dict->Capacity(); |
9373 for (uint32_t j = 0; j < capacity; j++) { | 9382 for (uint32_t j = 0; j < capacity; j++) { |
9374 HandleScope loop_scope(object->GetIsolate()); | 9383 HandleScope loop_scope(isolate); |
9375 Handle<Object> k(dict->KeyAt(j)); | 9384 Handle<Object> k(dict->KeyAt(j), isolate); |
9376 if (dict->IsKey(*k)) { | 9385 if (dict->IsKey(*k)) { |
9377 ASSERT(k->IsNumber()); | 9386 ASSERT(k->IsNumber()); |
9378 uint32_t index = static_cast<uint32_t>(k->Number()); | 9387 uint32_t index = static_cast<uint32_t>(k->Number()); |
9379 if (index < range) { | 9388 if (index < range) { |
9380 indices->Add(index); | 9389 indices->Add(index); |
9381 } | 9390 } |
9382 } | 9391 } |
9383 } | 9392 } |
9384 break; | 9393 break; |
9385 } | 9394 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9444 indices->Clear(); | 9453 indices->Clear(); |
9445 } | 9454 } |
9446 for (uint32_t i = 0; i < length; i++) { | 9455 for (uint32_t i = 0; i < length; i++) { |
9447 indices->Add(i); | 9456 indices->Add(i); |
9448 } | 9457 } |
9449 if (length == range) return; // All indices accounted for already. | 9458 if (length == range) return; // All indices accounted for already. |
9450 break; | 9459 break; |
9451 } | 9460 } |
9452 } | 9461 } |
9453 | 9462 |
9454 Handle<Object> prototype(object->GetPrototype()); | 9463 Handle<Object> prototype(object->GetPrototype(), isolate); |
9455 if (prototype->IsJSObject()) { | 9464 if (prototype->IsJSObject()) { |
9456 // The prototype will usually have no inherited element indices, | 9465 // The prototype will usually have no inherited element indices, |
9457 // but we have to check. | 9466 // but we have to check. |
9458 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices); | 9467 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices); |
9459 } | 9468 } |
9460 } | 9469 } |
9461 | 9470 |
9462 | 9471 |
9463 /** | 9472 /** |
9464 * A helper function that visits elements of a JSArray in numerical | 9473 * A helper function that visits elements of a JSArray in numerical |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9543 do { | 9552 do { |
9544 j++; | 9553 j++; |
9545 } while (j < n && indices[j] == index); | 9554 } while (j < n && indices[j] == index); |
9546 } | 9555 } |
9547 break; | 9556 break; |
9548 } | 9557 } |
9549 case EXTERNAL_PIXEL_ELEMENTS: { | 9558 case EXTERNAL_PIXEL_ELEMENTS: { |
9550 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( | 9559 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( |
9551 receiver->elements())); | 9560 receiver->elements())); |
9552 for (uint32_t j = 0; j < length; j++) { | 9561 for (uint32_t j = 0; j < length; j++) { |
9553 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j))); | 9562 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j)), isolate); |
9554 visitor->visit(j, e); | 9563 visitor->visit(j, e); |
9555 } | 9564 } |
9556 break; | 9565 break; |
9557 } | 9566 } |
9558 case EXTERNAL_BYTE_ELEMENTS: { | 9567 case EXTERNAL_BYTE_ELEMENTS: { |
9559 IterateExternalArrayElements<ExternalByteArray, int8_t>( | 9568 IterateExternalArrayElements<ExternalByteArray, int8_t>( |
9560 isolate, receiver, true, true, visitor); | 9569 isolate, receiver, true, true, visitor); |
9561 break; | 9570 break; |
9562 } | 9571 } |
9563 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 9572 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9623 // The actual length can be larger if any of the arguments have getters | 9632 // The actual length can be larger if any of the arguments have getters |
9624 // that mutate other arguments (but will otherwise be precise). | 9633 // that mutate other arguments (but will otherwise be precise). |
9625 // The number of elements is precise if there are no inherited elements. | 9634 // The number of elements is precise if there are no inherited elements. |
9626 | 9635 |
9627 ElementsKind kind = FAST_SMI_ELEMENTS; | 9636 ElementsKind kind = FAST_SMI_ELEMENTS; |
9628 | 9637 |
9629 uint32_t estimate_result_length = 0; | 9638 uint32_t estimate_result_length = 0; |
9630 uint32_t estimate_nof_elements = 0; | 9639 uint32_t estimate_nof_elements = 0; |
9631 for (int i = 0; i < argument_count; i++) { | 9640 for (int i = 0; i < argument_count; i++) { |
9632 HandleScope loop_scope(isolate); | 9641 HandleScope loop_scope(isolate); |
9633 Handle<Object> obj(elements->get(i)); | 9642 Handle<Object> obj(elements->get(i), isolate); |
9634 uint32_t length_estimate; | 9643 uint32_t length_estimate; |
9635 uint32_t element_estimate; | 9644 uint32_t element_estimate; |
9636 if (obj->IsJSArray()) { | 9645 if (obj->IsJSArray()) { |
9637 Handle<JSArray> array(Handle<JSArray>::cast(obj)); | 9646 Handle<JSArray> array(Handle<JSArray>::cast(obj)); |
9638 length_estimate = static_cast<uint32_t>(array->length()->Number()); | 9647 length_estimate = static_cast<uint32_t>(array->length()->Number()); |
9639 if (length_estimate != 0) { | 9648 if (length_estimate != 0) { |
9640 ElementsKind array_kind = | 9649 ElementsKind array_kind = |
9641 GetPackedElementsKind(array->map()->elements_kind()); | 9650 GetPackedElementsKind(array->map()->elements_kind()); |
9642 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) { | 9651 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) { |
9643 kind = array_kind; | 9652 kind = array_kind; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9678 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length; | 9687 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length; |
9679 | 9688 |
9680 Handle<FixedArray> storage; | 9689 Handle<FixedArray> storage; |
9681 if (fast_case) { | 9690 if (fast_case) { |
9682 if (kind == FAST_DOUBLE_ELEMENTS) { | 9691 if (kind == FAST_DOUBLE_ELEMENTS) { |
9683 Handle<FixedDoubleArray> double_storage = | 9692 Handle<FixedDoubleArray> double_storage = |
9684 isolate->factory()->NewFixedDoubleArray(estimate_result_length); | 9693 isolate->factory()->NewFixedDoubleArray(estimate_result_length); |
9685 int j = 0; | 9694 int j = 0; |
9686 bool failure = false; | 9695 bool failure = false; |
9687 for (int i = 0; i < argument_count; i++) { | 9696 for (int i = 0; i < argument_count; i++) { |
9688 Handle<Object> obj(elements->get(i)); | 9697 Handle<Object> obj(elements->get(i), isolate); |
9689 if (obj->IsSmi()) { | 9698 if (obj->IsSmi()) { |
9690 double_storage->set(j, Smi::cast(*obj)->value()); | 9699 double_storage->set(j, Smi::cast(*obj)->value()); |
9691 j++; | 9700 j++; |
9692 } else if (obj->IsNumber()) { | 9701 } else if (obj->IsNumber()) { |
9693 double_storage->set(j, obj->Number()); | 9702 double_storage->set(j, obj->Number()); |
9694 j++; | 9703 j++; |
9695 } else { | 9704 } else { |
9696 JSArray* array = JSArray::cast(*obj); | 9705 JSArray* array = JSArray::cast(*obj); |
9697 uint32_t length = static_cast<uint32_t>(array->length()->Number()); | 9706 uint32_t length = static_cast<uint32_t>(array->length()->Number()); |
9698 switch (array->map()->elements_kind()) { | 9707 switch (array->map()->elements_kind()) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9755 // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate | 9764 // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate |
9756 uint32_t at_least_space_for = estimate_nof_elements + | 9765 uint32_t at_least_space_for = estimate_nof_elements + |
9757 (estimate_nof_elements >> 2); | 9766 (estimate_nof_elements >> 2); |
9758 storage = Handle<FixedArray>::cast( | 9767 storage = Handle<FixedArray>::cast( |
9759 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); | 9768 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); |
9760 } | 9769 } |
9761 | 9770 |
9762 ArrayConcatVisitor visitor(isolate, storage, fast_case); | 9771 ArrayConcatVisitor visitor(isolate, storage, fast_case); |
9763 | 9772 |
9764 for (int i = 0; i < argument_count; i++) { | 9773 for (int i = 0; i < argument_count; i++) { |
9765 Handle<Object> obj(elements->get(i)); | 9774 Handle<Object> obj(elements->get(i), isolate); |
9766 if (obj->IsJSArray()) { | 9775 if (obj->IsJSArray()) { |
9767 Handle<JSArray> array = Handle<JSArray>::cast(obj); | 9776 Handle<JSArray> array = Handle<JSArray>::cast(obj); |
9768 if (!IterateElements(isolate, array, &visitor)) { | 9777 if (!IterateElements(isolate, array, &visitor)) { |
9769 return Failure::Exception(); | 9778 return Failure::Exception(); |
9770 } | 9779 } |
9771 } else { | 9780 } else { |
9772 visitor.visit(0, obj); | 9781 visitor.visit(0, obj); |
9773 visitor.increase_index_offset(1); | 9782 visitor.increase_index_offset(1); |
9774 } | 9783 } |
9775 } | 9784 } |
9776 | 9785 |
9777 return *visitor.ToArray(); | 9786 return *visitor.ToArray(); |
9778 } | 9787 } |
9779 | 9788 |
9780 | 9789 |
9781 // This will not allocate (flatten the string), but it may run | 9790 // This will not allocate (flatten the string), but it may run |
9782 // very slowly for very deeply nested ConsStrings. For debugging use only. | 9791 // very slowly for very deeply nested ConsStrings. For debugging use only. |
9783 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { | 9792 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { |
9784 NoHandleAllocation ha; | 9793 NoHandleAllocation ha(isolate); |
9785 ASSERT(args.length() == 1); | 9794 ASSERT(args.length() == 1); |
9786 | 9795 |
9787 CONVERT_ARG_CHECKED(String, string, 0); | 9796 CONVERT_ARG_CHECKED(String, string, 0); |
9788 ConsStringIteratorOp op; | 9797 ConsStringIteratorOp op; |
9789 StringCharacterStream stream(string, &op); | 9798 StringCharacterStream stream(string, &op); |
9790 while (stream.HasMore()) { | 9799 while (stream.HasMore()) { |
9791 uint16_t character = stream.GetNext(); | 9800 uint16_t character = stream.GetNext(); |
9792 PrintF("%c", character); | 9801 PrintF("%c", character); |
9793 } | 9802 } |
9794 return string; | 9803 return string; |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10626 Handle<SharedFunctionInfo> shared(function->shared()); | 10635 Handle<SharedFunctionInfo> shared(function->shared()); |
10627 Handle<ScopeInfo> scope_info(shared->scope_info()); | 10636 Handle<ScopeInfo> scope_info(shared->scope_info()); |
10628 | 10637 |
10629 // Allocate and initialize a JSObject with all the arguments, stack locals | 10638 // Allocate and initialize a JSObject with all the arguments, stack locals |
10630 // heap locals and extension properties of the debugged function. | 10639 // heap locals and extension properties of the debugged function. |
10631 Handle<JSObject> local_scope = | 10640 Handle<JSObject> local_scope = |
10632 isolate->factory()->NewJSObject(isolate->object_function()); | 10641 isolate->factory()->NewJSObject(isolate->object_function()); |
10633 | 10642 |
10634 // First fill all parameters. | 10643 // First fill all parameters. |
10635 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 10644 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
10636 Handle<Object> value( | 10645 Handle<Object> value(i < frame_inspector->GetParametersCount() |
10637 i < frame_inspector->GetParametersCount() ? | 10646 ? frame_inspector->GetParameter(i) |
10638 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value()); | 10647 : isolate->heap()->undefined_value(), |
| 10648 isolate); |
10639 | 10649 |
10640 RETURN_IF_EMPTY_HANDLE_VALUE( | 10650 RETURN_IF_EMPTY_HANDLE_VALUE( |
10641 isolate, | 10651 isolate, |
10642 SetProperty(isolate, | 10652 SetProperty(isolate, |
10643 local_scope, | 10653 local_scope, |
10644 Handle<String>(scope_info->ParameterName(i)), | 10654 Handle<String>(scope_info->ParameterName(i)), |
10645 value, | 10655 value, |
10646 NONE, | 10656 NONE, |
10647 kNonStrictMode), | 10657 kNonStrictMode), |
10648 Handle<JSObject>()); | 10658 Handle<JSObject>()); |
10649 } | 10659 } |
10650 | 10660 |
10651 // Second fill all stack locals. | 10661 // Second fill all stack locals. |
10652 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 10662 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
10653 RETURN_IF_EMPTY_HANDLE_VALUE( | 10663 RETURN_IF_EMPTY_HANDLE_VALUE( |
10654 isolate, | 10664 isolate, |
10655 SetProperty(isolate, | 10665 SetProperty(isolate, |
10656 local_scope, | 10666 local_scope, |
10657 Handle<String>(scope_info->StackLocalName(i)), | 10667 Handle<String>(scope_info->StackLocalName(i)), |
10658 Handle<Object>(frame_inspector->GetExpression(i)), | 10668 Handle<Object>(frame_inspector->GetExpression(i), isolate), |
10659 NONE, | 10669 NONE, |
10660 kNonStrictMode), | 10670 kNonStrictMode), |
10661 Handle<JSObject>()); | 10671 Handle<JSObject>()); |
10662 } | 10672 } |
10663 | 10673 |
10664 if (scope_info->HasContext()) { | 10674 if (scope_info->HasContext()) { |
10665 // Third fill all context locals. | 10675 // Third fill all context locals. |
10666 Handle<Context> frame_context(Context::cast(frame->context())); | 10676 Handle<Context> frame_context(Context::cast(frame->context())); |
10667 Handle<Context> function_context(frame_context->declaration_context()); | 10677 Handle<Context> function_context(frame_context->declaration_context()); |
10668 if (!CopyContextLocalsToScopeObject( | 10678 if (!CopyContextLocalsToScopeObject( |
(...skipping 14 matching lines...) Expand all Loading... |
10683 | 10693 |
10684 for (int i = 0; i < keys->length(); i++) { | 10694 for (int i = 0; i < keys->length(); i++) { |
10685 // Names of variables introduced by eval are strings. | 10695 // Names of variables introduced by eval are strings. |
10686 ASSERT(keys->get(i)->IsString()); | 10696 ASSERT(keys->get(i)->IsString()); |
10687 Handle<String> key(String::cast(keys->get(i))); | 10697 Handle<String> key(String::cast(keys->get(i))); |
10688 RETURN_IF_EMPTY_HANDLE_VALUE( | 10698 RETURN_IF_EMPTY_HANDLE_VALUE( |
10689 isolate, | 10699 isolate, |
10690 SetProperty(isolate, | 10700 SetProperty(isolate, |
10691 local_scope, | 10701 local_scope, |
10692 key, | 10702 key, |
10693 GetProperty(ext, key), | 10703 GetProperty(isolate, ext, key), |
10694 NONE, | 10704 NONE, |
10695 kNonStrictMode), | 10705 kNonStrictMode), |
10696 Handle<JSObject>()); | 10706 Handle<JSObject>()); |
10697 } | 10707 } |
10698 } | 10708 } |
10699 } | 10709 } |
10700 } | 10710 } |
10701 | 10711 |
10702 return local_scope; | 10712 return local_scope; |
10703 } | 10713 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10834 | 10844 |
10835 for (int i = 0; i < keys->length(); i++) { | 10845 for (int i = 0; i < keys->length(); i++) { |
10836 // Names of variables introduced by eval are strings. | 10846 // Names of variables introduced by eval are strings. |
10837 ASSERT(keys->get(i)->IsString()); | 10847 ASSERT(keys->get(i)->IsString()); |
10838 Handle<String> key(String::cast(keys->get(i))); | 10848 Handle<String> key(String::cast(keys->get(i))); |
10839 RETURN_IF_EMPTY_HANDLE_VALUE( | 10849 RETURN_IF_EMPTY_HANDLE_VALUE( |
10840 isolate, | 10850 isolate, |
10841 SetProperty(isolate, | 10851 SetProperty(isolate, |
10842 closure_scope, | 10852 closure_scope, |
10843 key, | 10853 key, |
10844 GetProperty(ext, key), | 10854 GetProperty(isolate, ext, key), |
10845 NONE, | 10855 NONE, |
10846 kNonStrictMode), | 10856 kNonStrictMode), |
10847 Handle<JSObject>()); | 10857 Handle<JSObject>()); |
10848 } | 10858 } |
10849 } | 10859 } |
10850 | 10860 |
10851 return closure_scope; | 10861 return closure_scope; |
10852 } | 10862 } |
10853 | 10863 |
10854 | 10864 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10887 return false; | 10897 return false; |
10888 } | 10898 } |
10889 | 10899 |
10890 | 10900 |
10891 // Create a plain JSObject which materializes the scope for the specified | 10901 // Create a plain JSObject which materializes the scope for the specified |
10892 // catch context. | 10902 // catch context. |
10893 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, | 10903 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, |
10894 Handle<Context> context) { | 10904 Handle<Context> context) { |
10895 ASSERT(context->IsCatchContext()); | 10905 ASSERT(context->IsCatchContext()); |
10896 Handle<String> name(String::cast(context->extension())); | 10906 Handle<String> name(String::cast(context->extension())); |
10897 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX)); | 10907 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), |
| 10908 isolate); |
10898 Handle<JSObject> catch_scope = | 10909 Handle<JSObject> catch_scope = |
10899 isolate->factory()->NewJSObject(isolate->object_function()); | 10910 isolate->factory()->NewJSObject(isolate->object_function()); |
10900 RETURN_IF_EMPTY_HANDLE_VALUE( | 10911 RETURN_IF_EMPTY_HANDLE_VALUE( |
10901 isolate, | 10912 isolate, |
10902 SetProperty(isolate, | 10913 SetProperty(isolate, |
10903 catch_scope, | 10914 catch_scope, |
10904 name, | 10915 name, |
10905 thrown_object, | 10916 thrown_object, |
10906 NONE, | 10917 NONE, |
10907 kNonStrictMode), | 10918 kNonStrictMode), |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11244 PrintF("Global:\n"); | 11255 PrintF("Global:\n"); |
11245 CurrentContext()->Print(); | 11256 CurrentContext()->Print(); |
11246 break; | 11257 break; |
11247 | 11258 |
11248 case ScopeIterator::ScopeTypeLocal: { | 11259 case ScopeIterator::ScopeTypeLocal: { |
11249 PrintF("Local:\n"); | 11260 PrintF("Local:\n"); |
11250 function_->shared()->scope_info()->Print(); | 11261 function_->shared()->scope_info()->Print(); |
11251 if (!CurrentContext().is_null()) { | 11262 if (!CurrentContext().is_null()) { |
11252 CurrentContext()->Print(); | 11263 CurrentContext()->Print(); |
11253 if (CurrentContext()->has_extension()) { | 11264 if (CurrentContext()->has_extension()) { |
11254 Handle<Object> extension(CurrentContext()->extension()); | 11265 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
11255 if (extension->IsJSContextExtensionObject()) { | 11266 if (extension->IsJSContextExtensionObject()) { |
11256 extension->Print(); | 11267 extension->Print(); |
11257 } | 11268 } |
11258 } | 11269 } |
11259 } | 11270 } |
11260 break; | 11271 break; |
11261 } | 11272 } |
11262 | 11273 |
11263 case ScopeIterator::ScopeTypeWith: | 11274 case ScopeIterator::ScopeTypeWith: |
11264 PrintF("With:\n"); | 11275 PrintF("With:\n"); |
11265 CurrentContext()->extension()->Print(); | 11276 CurrentContext()->extension()->Print(); |
11266 break; | 11277 break; |
11267 | 11278 |
11268 case ScopeIterator::ScopeTypeCatch: | 11279 case ScopeIterator::ScopeTypeCatch: |
11269 PrintF("Catch:\n"); | 11280 PrintF("Catch:\n"); |
11270 CurrentContext()->extension()->Print(); | 11281 CurrentContext()->extension()->Print(); |
11271 CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(); | 11282 CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(); |
11272 break; | 11283 break; |
11273 | 11284 |
11274 case ScopeIterator::ScopeTypeClosure: | 11285 case ScopeIterator::ScopeTypeClosure: |
11275 PrintF("Closure:\n"); | 11286 PrintF("Closure:\n"); |
11276 CurrentContext()->Print(); | 11287 CurrentContext()->Print(); |
11277 if (CurrentContext()->has_extension()) { | 11288 if (CurrentContext()->has_extension()) { |
11278 Handle<Object> extension(CurrentContext()->extension()); | 11289 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
11279 if (extension->IsJSContextExtensionObject()) { | 11290 if (extension->IsJSContextExtensionObject()) { |
11280 extension->Print(); | 11291 extension->Print(); |
11281 } | 11292 } |
11282 } | 11293 } |
11283 break; | 11294 break; |
11284 | 11295 |
11285 default: | 11296 default: |
11286 UNREACHABLE(); | 11297 UNREACHABLE(); |
11287 } | 11298 } |
11288 PrintF("\n"); | 11299 PrintF("\n"); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11807 Handle<Context> context = base; | 11818 Handle<Context> context = base; |
11808 | 11819 |
11809 // Iteratively copy and or materialize the nested contexts. | 11820 // Iteratively copy and or materialize the nested contexts. |
11810 while (!scope_chain.is_empty()) { | 11821 while (!scope_chain.is_empty()) { |
11811 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast(); | 11822 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast(); |
11812 Handle<Context> current = context_chain.RemoveLast(); | 11823 Handle<Context> current = context_chain.RemoveLast(); |
11813 ASSERT(!(scope_info->HasContext() & current.is_null())); | 11824 ASSERT(!(scope_info->HasContext() & current.is_null())); |
11814 | 11825 |
11815 if (scope_info->Type() == CATCH_SCOPE) { | 11826 if (scope_info->Type() == CATCH_SCOPE) { |
11816 Handle<String> name(String::cast(current->extension())); | 11827 Handle<String> name(String::cast(current->extension())); |
11817 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX)); | 11828 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX), |
| 11829 isolate); |
11818 context = | 11830 context = |
11819 isolate->factory()->NewCatchContext(function, | 11831 isolate->factory()->NewCatchContext(function, |
11820 context, | 11832 context, |
11821 name, | 11833 name, |
11822 thrown_object); | 11834 thrown_object); |
11823 } else if (scope_info->Type() == BLOCK_SCOPE) { | 11835 } else if (scope_info->Type() == BLOCK_SCOPE) { |
11824 // Materialize the contents of the block scope into a JSObject. | 11836 // Materialize the contents of the block scope into a JSObject. |
11825 Handle<JSObject> block_scope_object = | 11837 Handle<JSObject> block_scope_object = |
11826 MaterializeBlockScope(isolate, current); | 11838 MaterializeBlockScope(isolate, current); |
11827 CHECK(!block_scope_object.is_null()); | 11839 CHECK(!block_scope_object.is_null()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11915 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 11927 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
11916 RUNTIME_ARGUMENTS(isolate, args)); | 11928 RUNTIME_ARGUMENTS(isolate, args)); |
11917 if (!maybe_check_result->ToObject(&check_result)) { | 11929 if (!maybe_check_result->ToObject(&check_result)) { |
11918 return maybe_check_result; | 11930 return maybe_check_result; |
11919 } | 11931 } |
11920 } | 11932 } |
11921 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 11933 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
11922 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 11934 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
11923 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); | 11935 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); |
11924 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); | 11936 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); |
11925 Handle<Object> additional_context(args[5]); | 11937 Handle<Object> additional_context(args[5], isolate); |
11926 | 11938 |
11927 // Handle the processing of break. | 11939 // Handle the processing of break. |
11928 DisableBreak disable_break_save(disable_break); | 11940 DisableBreak disable_break_save(disable_break); |
11929 | 11941 |
11930 // Get the frame where the debugging is performed. | 11942 // Get the frame where the debugging is performed. |
11931 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 11943 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
11932 JavaScriptFrameIterator it(isolate, id); | 11944 JavaScriptFrameIterator it(isolate, id); |
11933 JavaScriptFrame* frame = it.frame(); | 11945 JavaScriptFrame* frame = it.frame(); |
11934 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 11946 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
11935 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 11947 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12075 ASSERT(args.length() == 4); | 12087 ASSERT(args.length() == 4); |
12076 Object* check_result; | 12088 Object* check_result; |
12077 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 12089 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
12078 RUNTIME_ARGUMENTS(isolate, args)); | 12090 RUNTIME_ARGUMENTS(isolate, args)); |
12079 if (!maybe_check_result->ToObject(&check_result)) { | 12091 if (!maybe_check_result->ToObject(&check_result)) { |
12080 return maybe_check_result; | 12092 return maybe_check_result; |
12081 } | 12093 } |
12082 } | 12094 } |
12083 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 12095 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
12084 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 12096 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
12085 Handle<Object> additional_context(args[3]); | 12097 Handle<Object> additional_context(args[3], isolate); |
12086 | 12098 |
12087 // Handle the processing of break. | 12099 // Handle the processing of break. |
12088 DisableBreak disable_break_save(disable_break); | 12100 DisableBreak disable_break_save(disable_break); |
12089 | 12101 |
12090 // Enter the top context from before the debugger was invoked. | 12102 // Enter the top context from before the debugger was invoked. |
12091 SaveContext save(isolate); | 12103 SaveContext save(isolate); |
12092 SaveContext* top = &save; | 12104 SaveContext* top = &save; |
12093 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { | 12105 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { |
12094 top = top->prev(); | 12106 top = top->prev(); |
12095 } | 12107 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12167 return *result; | 12179 return *result; |
12168 } | 12180 } |
12169 | 12181 |
12170 | 12182 |
12171 // Helper function used by Runtime_DebugReferencedBy below. | 12183 // Helper function used by Runtime_DebugReferencedBy below. |
12172 static int DebugReferencedBy(HeapIterator* iterator, | 12184 static int DebugReferencedBy(HeapIterator* iterator, |
12173 JSObject* target, | 12185 JSObject* target, |
12174 Object* instance_filter, int max_references, | 12186 Object* instance_filter, int max_references, |
12175 FixedArray* instances, int instances_size, | 12187 FixedArray* instances, int instances_size, |
12176 JSFunction* arguments_function) { | 12188 JSFunction* arguments_function) { |
12177 NoHandleAllocation ha; | 12189 NoHandleAllocation ha(target->GetIsolate()); |
12178 AssertNoAllocation no_alloc; | 12190 AssertNoAllocation no_alloc; |
12179 | 12191 |
12180 // Iterate the heap. | 12192 // Iterate the heap. |
12181 int count = 0; | 12193 int count = 0; |
12182 JSObject* last = NULL; | 12194 JSObject* last = NULL; |
12183 HeapObject* heap_obj = NULL; | 12195 HeapObject* heap_obj = NULL; |
12184 while (((heap_obj = iterator->next()) != NULL) && | 12196 while (((heap_obj = iterator->next()) != NULL) && |
12185 (max_references == 0 || count < max_references)) { | 12197 (max_references == 0 || count < max_references)) { |
12186 // Only look at all JSObjects. | 12198 // Only look at all JSObjects. |
12187 if (heap_obj->IsJSObject()) { | 12199 if (heap_obj->IsJSObject()) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12444 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { | 12456 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { |
12445 return Failure::Exception(); | 12457 return Failure::Exception(); |
12446 } | 12458 } |
12447 func->shared()->construct_stub()->PrintLn(); | 12459 func->shared()->construct_stub()->PrintLn(); |
12448 #endif // DEBUG | 12460 #endif // DEBUG |
12449 return isolate->heap()->undefined_value(); | 12461 return isolate->heap()->undefined_value(); |
12450 } | 12462 } |
12451 | 12463 |
12452 | 12464 |
12453 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { | 12465 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { |
12454 NoHandleAllocation ha; | 12466 NoHandleAllocation ha(isolate); |
12455 ASSERT(args.length() == 1); | 12467 ASSERT(args.length() == 1); |
12456 | 12468 |
12457 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 12469 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
12458 return f->shared()->inferred_name(); | 12470 return f->shared()->inferred_name(); |
12459 } | 12471 } |
12460 | 12472 |
12461 | 12473 |
12462 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 12474 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
12463 Script* script, | 12475 Script* script, |
12464 FixedArray* buffer) { | 12476 FixedArray* buffer) { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12821 if (!Smi::IsValid(usage)) { | 12833 if (!Smi::IsValid(usage)) { |
12822 return *isolate->factory()->NewNumberFromInt(usage); | 12834 return *isolate->factory()->NewNumberFromInt(usage); |
12823 } | 12835 } |
12824 return Smi::FromInt(usage); | 12836 return Smi::FromInt(usage); |
12825 } | 12837 } |
12826 | 12838 |
12827 #endif // ENABLE_DEBUGGER_SUPPORT | 12839 #endif // ENABLE_DEBUGGER_SUPPORT |
12828 | 12840 |
12829 | 12841 |
12830 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { | 12842 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { |
12831 NoHandleAllocation ha; | 12843 NoHandleAllocation ha(isolate); |
12832 v8::V8::ResumeProfiler(); | 12844 v8::V8::ResumeProfiler(); |
12833 return isolate->heap()->undefined_value(); | 12845 return isolate->heap()->undefined_value(); |
12834 } | 12846 } |
12835 | 12847 |
12836 | 12848 |
12837 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { | 12849 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { |
12838 NoHandleAllocation ha; | 12850 NoHandleAllocation ha(isolate); |
12839 v8::V8::PauseProfiler(); | 12851 v8::V8::PauseProfiler(); |
12840 return isolate->heap()->undefined_value(); | 12852 return isolate->heap()->undefined_value(); |
12841 } | 12853 } |
12842 | 12854 |
12843 | 12855 |
12844 // Finds the script object from the script data. NOTE: This operation uses | 12856 // Finds the script object from the script data. NOTE: This operation uses |
12845 // heap traversal to find the function generated for the source position | 12857 // heap traversal to find the function generated for the source position |
12846 // for the requested break point. For lazily compiled functions several heap | 12858 // for the requested break point. For lazily compiled functions several heap |
12847 // traversals might be required rendering this operation as a rather slow | 12859 // traversals might be required rendering this operation as a rather slow |
12848 // operation. However for setting break points which is normally done through | 12860 // operation. However for setting break points which is normally done through |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12950 JSObject::SetHiddenProperty(error_object, key, value); | 12962 JSObject::SetHiddenProperty(error_object, key, value); |
12951 } | 12963 } |
12952 return *error_object; | 12964 return *error_object; |
12953 } | 12965 } |
12954 | 12966 |
12955 | 12967 |
12956 // Returns V8 version as a string. | 12968 // Returns V8 version as a string. |
12957 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 12969 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
12958 ASSERT_EQ(args.length(), 0); | 12970 ASSERT_EQ(args.length(), 0); |
12959 | 12971 |
12960 NoHandleAllocation ha; | 12972 NoHandleAllocation ha(isolate); |
12961 | 12973 |
12962 const char* version_string = v8::V8::GetVersion(); | 12974 const char* version_string = v8::V8::GetVersion(); |
12963 | 12975 |
12964 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), | 12976 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), |
12965 NOT_TENURED); | 12977 NOT_TENURED); |
12966 } | 12978 } |
12967 | 12979 |
12968 | 12980 |
12969 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 12981 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { |
12970 ASSERT(args.length() == 2); | 12982 ASSERT(args.length() == 2); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13016 if (o == key) { | 13028 if (o == key) { |
13017 cache->set_finger_index(i); | 13029 cache->set_finger_index(i); |
13018 return cache->get(i + 1); | 13030 return cache->get(i + 1); |
13019 } | 13031 } |
13020 } | 13032 } |
13021 | 13033 |
13022 // There is no value in the cache. Invoke the function and cache result. | 13034 // There is no value in the cache. Invoke the function and cache result. |
13023 HandleScope scope(isolate); | 13035 HandleScope scope(isolate); |
13024 | 13036 |
13025 Handle<JSFunctionResultCache> cache_handle(cache); | 13037 Handle<JSFunctionResultCache> cache_handle(cache); |
13026 Handle<Object> key_handle(key); | 13038 Handle<Object> key_handle(key, isolate); |
13027 Handle<Object> value; | 13039 Handle<Object> value; |
13028 { | 13040 { |
13029 Handle<JSFunction> factory(JSFunction::cast( | 13041 Handle<JSFunction> factory(JSFunction::cast( |
13030 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); | 13042 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); |
13031 // TODO(antonm): consider passing a receiver when constructing a cache. | 13043 // TODO(antonm): consider passing a receiver when constructing a cache. |
13032 Handle<Object> receiver(isolate->native_context()->global_object()); | 13044 Handle<Object> receiver(isolate->native_context()->global_object(), |
| 13045 isolate); |
13033 // This handle is nor shared, nor used later, so it's safe. | 13046 // This handle is nor shared, nor used later, so it's safe. |
13034 Handle<Object> argv[] = { key_handle }; | 13047 Handle<Object> argv[] = { key_handle }; |
13035 bool pending_exception; | 13048 bool pending_exception; |
13036 value = Execution::Call(factory, | 13049 value = Execution::Call(factory, |
13037 receiver, | 13050 receiver, |
13038 ARRAY_SIZE(argv), | 13051 ARRAY_SIZE(argv), |
13039 argv, | 13052 argv, |
13040 &pending_exception); | 13053 &pending_exception); |
13041 if (pending_exception) return Failure::Exception(); | 13054 if (pending_exception) return Failure::Exception(); |
13042 } | 13055 } |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13355 // Handle last resort GC and make sure to allow future allocations | 13368 // Handle last resort GC and make sure to allow future allocations |
13356 // to grow the heap without causing GCs (if possible). | 13369 // to grow the heap without causing GCs (if possible). |
13357 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13370 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13358 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13371 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13359 "Runtime::PerformGC"); | 13372 "Runtime::PerformGC"); |
13360 } | 13373 } |
13361 } | 13374 } |
13362 | 13375 |
13363 | 13376 |
13364 } } // namespace v8::internal | 13377 } } // namespace v8::internal |
OLD | NEW |