Chromium Code Reviews| 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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); | 753 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); |
| 754 holder->set_table(*table); | 754 holder->set_table(*table); |
| 755 return *holder; | 755 return *holder; |
| 756 } | 756 } |
| 757 | 757 |
| 758 | 758 |
| 759 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { | 759 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { |
| 760 HandleScope scope(isolate); | 760 HandleScope scope(isolate); |
| 761 ASSERT(args.length() == 2); | 761 ASSERT(args.length() == 2); |
| 762 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 762 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 763 Handle<Object> key(args[1]); | 763 Handle<Object> key(args[1], isolate); |
| 764 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | 764 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
| 765 table = ObjectHashSetAdd(table, key); | 765 table = ObjectHashSetAdd(table, key); |
| 766 holder->set_table(*table); | 766 holder->set_table(*table); |
| 767 return isolate->heap()->undefined_value(); | 767 return isolate->heap()->undefined_value(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { | 771 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { |
| 772 HandleScope scope(isolate); | 772 HandleScope scope(isolate); |
| 773 ASSERT(args.length() == 2); | 773 ASSERT(args.length() == 2); |
| 774 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 774 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 775 Handle<Object> key(args[1]); | 775 Handle<Object> key(args[1], isolate); |
| 776 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | 776 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
| 777 return isolate->heap()->ToBoolean(table->Contains(*key)); | 777 return isolate->heap()->ToBoolean(table->Contains(*key)); |
| 778 } | 778 } |
| 779 | 779 |
| 780 | 780 |
| 781 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { | 781 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { |
| 782 HandleScope scope(isolate); | 782 HandleScope scope(isolate); |
| 783 ASSERT(args.length() == 2); | 783 ASSERT(args.length() == 2); |
| 784 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 784 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
| 785 Handle<Object> key(args[1]); | 785 Handle<Object> key(args[1], isolate); |
| 786 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | 786 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
| 787 table = ObjectHashSetRemove(table, key); | 787 table = ObjectHashSetRemove(table, key); |
| 788 holder->set_table(*table); | 788 holder->set_table(*table); |
| 789 return isolate->heap()->undefined_value(); | 789 return isolate->heap()->undefined_value(); |
| 790 } | 790 } |
| 791 | 791 |
| 792 | 792 |
| 793 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { | 793 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { |
| 794 HandleScope scope(isolate); | 794 HandleScope scope(isolate); |
| 795 ASSERT(args.length() == 1); | 795 ASSERT(args.length() == 1); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 808 return *holder; | 808 return *holder; |
| 809 } | 809 } |
| 810 | 810 |
| 811 | 811 |
| 812 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { | 812 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { |
| 813 HandleScope scope(isolate); | 813 HandleScope scope(isolate); |
| 814 ASSERT(args.length() == 2); | 814 ASSERT(args.length() == 2); |
| 815 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 815 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 816 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 816 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 817 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 817 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 818 Handle<Object> lookup(table->Lookup(*key)); | 818 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 819 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 819 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 820 } | 820 } |
| 821 | 821 |
| 822 | 822 |
| 823 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { | 823 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { |
| 824 HandleScope scope(isolate); | 824 HandleScope scope(isolate); |
| 825 ASSERT(args.length() == 2); | 825 ASSERT(args.length() == 2); |
| 826 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 826 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 827 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 827 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 828 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 828 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 829 Handle<Object> lookup(table->Lookup(*key)); | 829 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 830 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 830 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 831 } | 831 } |
| 832 | 832 |
| 833 | 833 |
| 834 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { | 834 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { |
| 835 HandleScope scope(isolate); | 835 HandleScope scope(isolate); |
| 836 ASSERT(args.length() == 2); | 836 ASSERT(args.length() == 2); |
| 837 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 837 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 838 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 838 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 839 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 839 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 840 Handle<Object> lookup(table->Lookup(*key)); | 840 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 841 Handle<ObjectHashTable> new_table = | 841 Handle<ObjectHashTable> new_table = |
| 842 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); | 842 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
| 843 holder->set_table(*new_table); | 843 holder->set_table(*new_table); |
| 844 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 844 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 845 } | 845 } |
| 846 | 846 |
| 847 | 847 |
| 848 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { | 848 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { |
| 849 HandleScope scope(isolate); | 849 HandleScope scope(isolate); |
| 850 ASSERT(args.length() == 3); | 850 ASSERT(args.length() == 3); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 return WeakMapInitialize(isolate, weakmap); | 884 return WeakMapInitialize(isolate, weakmap); |
| 885 } | 885 } |
| 886 | 886 |
| 887 | 887 |
| 888 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { | 888 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { |
| 889 HandleScope scope(isolate); | 889 HandleScope scope(isolate); |
| 890 ASSERT(args.length() == 2); | 890 ASSERT(args.length() == 2); |
| 891 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 891 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 892 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 892 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 893 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 893 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 894 Handle<Object> lookup(table->Lookup(*key)); | 894 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 895 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 895 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 896 } | 896 } |
| 897 | 897 |
| 898 | 898 |
| 899 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { | 899 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { |
| 900 HandleScope scope(isolate); | 900 HandleScope scope(isolate); |
| 901 ASSERT(args.length() == 2); | 901 ASSERT(args.length() == 2); |
| 902 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 902 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 903 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 903 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 904 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 904 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 905 Handle<Object> lookup(table->Lookup(*key)); | 905 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 906 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 906 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 907 } | 907 } |
| 908 | 908 |
| 909 | 909 |
| 910 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { | 910 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { |
| 911 HandleScope scope(isolate); | 911 HandleScope scope(isolate); |
| 912 ASSERT(args.length() == 2); | 912 ASSERT(args.length() == 2); |
| 913 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 913 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 914 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 914 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 915 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 915 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 916 Handle<Object> lookup(table->Lookup(*key)); | 916 Handle<Object> lookup(table->Lookup(*key), isolate); |
| 917 Handle<ObjectHashTable> new_table = | 917 Handle<ObjectHashTable> new_table = |
| 918 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); | 918 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
| 919 weakmap->set_table(*new_table); | 919 weakmap->set_table(*new_table); |
| 920 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 920 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 921 } | 921 } |
| 922 | 922 |
| 923 | 923 |
| 924 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { | 924 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { |
| 925 HandleScope scope(isolate); | 925 HandleScope scope(isolate); |
| 926 ASSERT(args.length() == 3); | 926 ASSERT(args.length() == 3); |
| 927 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 927 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 928 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 928 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 929 Handle<Object> value(args[2]); | 929 Handle<Object> value(args[2], isolate); |
| 930 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 930 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 931 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | 931 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
| 932 weakmap->set_table(*new_table); | 932 weakmap->set_table(*new_table); |
| 933 return isolate->heap()->undefined_value(); | 933 return isolate->heap()->undefined_value(); |
| 934 } | 934 } |
| 935 | 935 |
| 936 | 936 |
| 937 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 937 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
| 938 NoHandleAllocation ha; | 938 NoHandleAllocation ha(isolate); |
| 939 ASSERT(args.length() == 1); | 939 ASSERT(args.length() == 1); |
| 940 Object* obj = args[0]; | 940 Object* obj = args[0]; |
| 941 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 941 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
| 942 return JSObject::cast(obj)->class_name(); | 942 return JSObject::cast(obj)->class_name(); |
| 943 } | 943 } |
| 944 | 944 |
| 945 | 945 |
| 946 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 946 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
| 947 NoHandleAllocation ha; | 947 NoHandleAllocation ha(isolate); |
| 948 ASSERT(args.length() == 1); | 948 ASSERT(args.length() == 1); |
| 949 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0); | 949 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0); |
| 950 Object* obj = input_obj; | 950 Object* obj = input_obj; |
| 951 // We don't expect access checks to be needed on JSProxy objects. | 951 // We don't expect access checks to be needed on JSProxy objects. |
| 952 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 952 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 953 do { | 953 do { |
| 954 if (obj->IsAccessCheckNeeded() && | 954 if (obj->IsAccessCheckNeeded() && |
| 955 !isolate->MayNamedAccess(JSObject::cast(obj), | 955 !isolate->MayNamedAccess(JSObject::cast(obj), |
| 956 isolate->heap()->Proto_symbol(), | 956 isolate->heap()->Proto_symbol(), |
| 957 v8::ACCESS_GET)) { | 957 v8::ACCESS_GET)) { |
| 958 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); | 958 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); |
| 959 return isolate->heap()->undefined_value(); | 959 return isolate->heap()->undefined_value(); |
| 960 } | 960 } |
| 961 obj = obj->GetPrototype(); | 961 obj = obj->GetPrototype(); |
| 962 } while (obj->IsJSObject() && | 962 } while (obj->IsJSObject() && |
| 963 JSObject::cast(obj)->map()->is_hidden_prototype()); | 963 JSObject::cast(obj)->map()->is_hidden_prototype()); |
| 964 return obj; | 964 return obj; |
| 965 } | 965 } |
| 966 | 966 |
| 967 | 967 |
| 968 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 968 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
| 969 NoHandleAllocation ha; | 969 NoHandleAllocation ha(isolate); |
| 970 ASSERT(args.length() == 2); | 970 ASSERT(args.length() == 2); |
| 971 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 971 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
| 972 Object* O = args[0]; | 972 Object* O = args[0]; |
| 973 Object* V = args[1]; | 973 Object* V = args[1]; |
| 974 while (true) { | 974 while (true) { |
| 975 Object* prototype = V->GetPrototype(); | 975 Object* prototype = V->GetPrototype(); |
| 976 if (prototype->IsNull()) return isolate->heap()->false_value(); | 976 if (prototype->IsNull()) return isolate->heap()->false_value(); |
| 977 if (O == prototype) return isolate->heap()->true_value(); | 977 if (O == prototype) return isolate->heap()->true_value(); |
| 978 V = prototype; | 978 V = prototype; |
| 979 } | 979 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 Handle<AccessorPair> accessors(raw_accessors, isolate); | 1115 Handle<AccessorPair> accessors(raw_accessors, isolate); |
| 1116 | 1116 |
| 1117 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 1117 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
| 1118 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 1118 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
| 1119 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 1119 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
| 1120 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); | 1120 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); |
| 1121 | 1121 |
| 1122 if (raw_accessors == NULL) { | 1122 if (raw_accessors == NULL) { |
| 1123 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 1123 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
| 1124 // GetProperty does access check. | 1124 // GetProperty does access check. |
| 1125 Handle<Object> value = GetProperty(obj, name); | 1125 Handle<Object> value = GetProperty(isolate, obj, name); |
| 1126 if (value.is_null()) return Failure::Exception(); | 1126 if (value.is_null()) return Failure::Exception(); |
| 1127 elms->set(VALUE_INDEX, *value); | 1127 elms->set(VALUE_INDEX, *value); |
| 1128 } else { | 1128 } else { |
| 1129 // Access checks are performed for both accessors separately. | 1129 // Access checks are performed for both accessors separately. |
| 1130 // When they fail, the respective field is not set in the descriptor. | 1130 // When they fail, the respective field is not set in the descriptor. |
| 1131 Object* getter = accessors->GetComponent(ACCESSOR_GETTER); | 1131 Object* getter = accessors->GetComponent(ACCESSOR_GETTER); |
| 1132 Object* setter = accessors->GetComponent(ACCESSOR_SETTER); | 1132 Object* setter = accessors->GetComponent(ACCESSOR_SETTER); |
| 1133 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) { | 1133 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) { |
| 1134 elms->set(GETTER_INDEX, getter); | 1134 elms->set(GETTER_INDEX, getter); |
| 1135 } | 1135 } |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1469 RETURN_IF_EMPTY_HANDLE(isolate, | 1469 RETURN_IF_EMPTY_HANDLE(isolate, |
| 1470 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); | 1470 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); |
| 1471 } | 1471 } |
| 1472 } | 1472 } |
| 1473 | 1473 |
| 1474 return isolate->heap()->undefined_value(); | 1474 return isolate->heap()->undefined_value(); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 | 1477 |
| 1478 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 1478 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
| 1479 NoHandleAllocation nha; | 1479 NoHandleAllocation nha(isolate); |
| 1480 // args[0] == name | 1480 // args[0] == name |
| 1481 // args[1] == language_mode | 1481 // args[1] == language_mode |
| 1482 // args[2] == value (optional) | 1482 // args[2] == value (optional) |
| 1483 | 1483 |
| 1484 // Determine if we need to assign to the variable if it already | 1484 // Determine if we need to assign to the variable if it already |
| 1485 // exists (based on the number of arguments). | 1485 // exists (based on the number of arguments). |
| 1486 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 1486 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
| 1487 bool assign = args.length() == 3; | 1487 bool assign = args.length() == 3; |
| 1488 | 1488 |
| 1489 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 1489 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1942 if (has_pending_exception) { | 1942 if (has_pending_exception) { |
| 1943 ASSERT(isolate->has_pending_exception()); | 1943 ASSERT(isolate->has_pending_exception()); |
| 1944 return Failure::Exception(); | 1944 return Failure::Exception(); |
| 1945 } | 1945 } |
| 1946 literals->set(index, *regexp); | 1946 literals->set(index, *regexp); |
| 1947 return *regexp; | 1947 return *regexp; |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 | 1950 |
| 1951 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { | 1951 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { |
| 1952 NoHandleAllocation ha; | 1952 NoHandleAllocation ha(isolate); |
| 1953 ASSERT(args.length() == 1); | 1953 ASSERT(args.length() == 1); |
| 1954 | 1954 |
| 1955 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1955 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 1956 return f->shared()->name(); | 1956 return f->shared()->name(); |
| 1957 } | 1957 } |
| 1958 | 1958 |
| 1959 | 1959 |
| 1960 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { | 1960 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { |
| 1961 NoHandleAllocation ha; | 1961 NoHandleAllocation ha(isolate); |
| 1962 ASSERT(args.length() == 2); | 1962 ASSERT(args.length() == 2); |
| 1963 | 1963 |
| 1964 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1964 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 1965 CONVERT_ARG_CHECKED(String, name, 1); | 1965 CONVERT_ARG_CHECKED(String, name, 1); |
| 1966 f->shared()->set_name(name); | 1966 f->shared()->set_name(name); |
| 1967 return isolate->heap()->undefined_value(); | 1967 return isolate->heap()->undefined_value(); |
| 1968 } | 1968 } |
| 1969 | 1969 |
| 1970 | 1970 |
| 1971 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { | 1971 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 1972 NoHandleAllocation ha; | 1972 NoHandleAllocation ha(isolate); |
| 1973 ASSERT(args.length() == 1); | 1973 ASSERT(args.length() == 1); |
| 1974 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1974 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 1975 return isolate->heap()->ToBoolean( | 1975 return isolate->heap()->ToBoolean( |
| 1976 f->shared()->name_should_print_as_anonymous()); | 1976 f->shared()->name_should_print_as_anonymous()); |
| 1977 } | 1977 } |
| 1978 | 1978 |
| 1979 | 1979 |
| 1980 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 1980 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
| 1981 NoHandleAllocation ha; | 1981 NoHandleAllocation ha(isolate); |
| 1982 ASSERT(args.length() == 1); | 1982 ASSERT(args.length() == 1); |
| 1983 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1983 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 1984 f->shared()->set_name_should_print_as_anonymous(true); | 1984 f->shared()->set_name_should_print_as_anonymous(true); |
| 1985 return isolate->heap()->undefined_value(); | 1985 return isolate->heap()->undefined_value(); |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 | 1988 |
| 1989 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 1989 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
| 1990 NoHandleAllocation ha; | 1990 NoHandleAllocation ha(isolate); |
| 1991 ASSERT(args.length() == 1); | 1991 ASSERT(args.length() == 1); |
| 1992 | 1992 |
| 1993 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 1993 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 1994 f->RemovePrototype(); | 1994 f->RemovePrototype(); |
| 1995 | 1995 |
| 1996 return isolate->heap()->undefined_value(); | 1996 return isolate->heap()->undefined_value(); |
| 1997 } | 1997 } |
| 1998 | 1998 |
| 1999 | 1999 |
| 2000 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { | 2000 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2013 HandleScope scope(isolate); | 2013 HandleScope scope(isolate); |
| 2014 ASSERT(args.length() == 1); | 2014 ASSERT(args.length() == 1); |
| 2015 | 2015 |
| 2016 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 2016 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
| 2017 Handle<SharedFunctionInfo> shared(f->shared()); | 2017 Handle<SharedFunctionInfo> shared(f->shared()); |
| 2018 return *shared->GetSourceCode(); | 2018 return *shared->GetSourceCode(); |
| 2019 } | 2019 } |
| 2020 | 2020 |
| 2021 | 2021 |
| 2022 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { | 2022 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { |
| 2023 NoHandleAllocation ha; | 2023 NoHandleAllocation ha(isolate); |
| 2024 ASSERT(args.length() == 1); | 2024 ASSERT(args.length() == 1); |
| 2025 | 2025 |
| 2026 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2026 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2027 int pos = fun->shared()->start_position(); | 2027 int pos = fun->shared()->start_position(); |
| 2028 return Smi::FromInt(pos); | 2028 return Smi::FromInt(pos); |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 | 2031 |
| 2032 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { | 2032 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { |
| 2033 ASSERT(args.length() == 2); | 2033 ASSERT(args.length() == 2); |
| 2034 | 2034 |
| 2035 CONVERT_ARG_CHECKED(Code, code, 0); | 2035 CONVERT_ARG_CHECKED(Code, code, 0); |
| 2036 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2036 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
| 2037 | 2037 |
| 2038 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2038 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
| 2039 | 2039 |
| 2040 Address pc = code->address() + offset; | 2040 Address pc = code->address() + offset; |
| 2041 return Smi::FromInt(code->SourcePosition(pc)); | 2041 return Smi::FromInt(code->SourcePosition(pc)); |
| 2042 } | 2042 } |
| 2043 | 2043 |
| 2044 | 2044 |
| 2045 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { | 2045 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { |
| 2046 NoHandleAllocation ha; | 2046 NoHandleAllocation ha(isolate); |
| 2047 ASSERT(args.length() == 2); | 2047 ASSERT(args.length() == 2); |
| 2048 | 2048 |
| 2049 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2049 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2050 CONVERT_ARG_CHECKED(String, name, 1); | 2050 CONVERT_ARG_CHECKED(String, name, 1); |
| 2051 fun->SetInstanceClassName(name); | 2051 fun->SetInstanceClassName(name); |
| 2052 return isolate->heap()->undefined_value(); | 2052 return isolate->heap()->undefined_value(); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 | 2055 |
| 2056 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { | 2056 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { |
| 2057 NoHandleAllocation ha; | 2057 NoHandleAllocation ha(isolate); |
| 2058 ASSERT(args.length() == 2); | 2058 ASSERT(args.length() == 2); |
| 2059 | 2059 |
| 2060 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2060 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2061 CONVERT_SMI_ARG_CHECKED(length, 1); | 2061 CONVERT_SMI_ARG_CHECKED(length, 1); |
| 2062 fun->shared()->set_length(length); | 2062 fun->shared()->set_length(length); |
| 2063 return isolate->heap()->undefined_value(); | 2063 return isolate->heap()->undefined_value(); |
| 2064 } | 2064 } |
| 2065 | 2065 |
| 2066 | 2066 |
| 2067 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 2067 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { |
| 2068 NoHandleAllocation ha; | 2068 NoHandleAllocation ha(isolate); |
| 2069 ASSERT(args.length() == 2); | 2069 ASSERT(args.length() == 2); |
| 2070 | 2070 |
| 2071 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2071 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2072 ASSERT(fun->should_have_prototype()); | 2072 ASSERT(fun->should_have_prototype()); |
| 2073 Object* obj; | 2073 Object* obj; |
| 2074 { MaybeObject* maybe_obj = | 2074 { MaybeObject* maybe_obj = |
| 2075 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 2075 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
| 2076 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2076 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2077 } | 2077 } |
| 2078 return args[0]; // return TOS | 2078 return args[0]; // return TOS |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 | 2081 |
| 2082 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2082 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
| 2083 NoHandleAllocation ha; | 2083 NoHandleAllocation ha(isolate); |
| 2084 RUNTIME_ASSERT(args.length() == 1); | 2084 RUNTIME_ASSERT(args.length() == 1); |
| 2085 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 2085 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 2086 | 2086 |
| 2087 String* name = isolate->heap()->prototype_symbol(); | 2087 String* name = isolate->heap()->prototype_symbol(); |
| 2088 | 2088 |
| 2089 if (function->HasFastProperties()) { | 2089 if (function->HasFastProperties()) { |
| 2090 // Construct a new field descriptor with updated attributes. | 2090 // Construct a new field descriptor with updated attributes. |
| 2091 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2091 DescriptorArray* instance_desc = function->map()->instance_descriptors(); |
| 2092 | 2092 |
| 2093 int index = instance_desc->SearchWithCache(name, function->map()); | 2093 int index = instance_desc->SearchWithCache(name, function->map()); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2116 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2116 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
| 2117 details.type(), | 2117 details.type(), |
| 2118 details.dictionary_index()); | 2118 details.dictionary_index()); |
| 2119 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2119 function->property_dictionary()->DetailsAtPut(entry, new_details); |
| 2120 } | 2120 } |
| 2121 return function; | 2121 return function; |
| 2122 } | 2122 } |
| 2123 | 2123 |
| 2124 | 2124 |
| 2125 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2125 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
| 2126 NoHandleAllocation ha; | 2126 NoHandleAllocation ha(isolate); |
| 2127 ASSERT(args.length() == 1); | 2127 ASSERT(args.length() == 1); |
| 2128 | 2128 |
| 2129 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2129 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2130 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 2130 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
| 2131 } | 2131 } |
| 2132 | 2132 |
| 2133 | 2133 |
| 2134 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 2134 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
| 2135 NoHandleAllocation ha; | 2135 NoHandleAllocation ha(isolate); |
| 2136 ASSERT(args.length() == 1); | 2136 ASSERT(args.length() == 1); |
| 2137 | 2137 |
| 2138 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2138 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2139 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 2139 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
| 2140 } | 2140 } |
| 2141 | 2141 |
| 2142 | 2142 |
| 2143 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 2143 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
| 2144 HandleScope scope(isolate); | 2144 HandleScope scope(isolate); |
| 2145 ASSERT(args.length() == 2); | 2145 ASSERT(args.length() == 2); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2220 if (char_code->ToArrayIndex(&code)) { | 2220 if (char_code->ToArrayIndex(&code)) { |
| 2221 if (code <= 0xffff) { | 2221 if (code <= 0xffff) { |
| 2222 return isolate->heap()->LookupSingleCharacterStringFromCode(code); | 2222 return isolate->heap()->LookupSingleCharacterStringFromCode(code); |
| 2223 } | 2223 } |
| 2224 } | 2224 } |
| 2225 return isolate->heap()->empty_string(); | 2225 return isolate->heap()->empty_string(); |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 | 2228 |
| 2229 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { | 2229 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { |
| 2230 NoHandleAllocation ha; | 2230 NoHandleAllocation ha(isolate); |
| 2231 ASSERT(args.length() == 2); | 2231 ASSERT(args.length() == 2); |
| 2232 | 2232 |
| 2233 CONVERT_ARG_CHECKED(String, subject, 0); | 2233 CONVERT_ARG_CHECKED(String, subject, 0); |
| 2234 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 2234 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
| 2235 | 2235 |
| 2236 // Flatten the string. If someone wants to get a char at an index | 2236 // Flatten the string. If someone wants to get a char at an index |
| 2237 // in a cons string, it is likely that more indices will be | 2237 // in a cons string, it is likely that more indices will be |
| 2238 // accessed. | 2238 // accessed. |
| 2239 Object* flat; | 2239 Object* flat; |
| 2240 { MaybeObject* maybe_flat = subject->TryFlatten(); | 2240 { MaybeObject* maybe_flat = subject->TryFlatten(); |
| 2241 if (!maybe_flat->ToObject(&flat)) return maybe_flat; | 2241 if (!maybe_flat->ToObject(&flat)) return maybe_flat; |
| 2242 } | 2242 } |
| 2243 subject = String::cast(flat); | 2243 subject = String::cast(flat); |
| 2244 | 2244 |
| 2245 if (i >= static_cast<uint32_t>(subject->length())) { | 2245 if (i >= static_cast<uint32_t>(subject->length())) { |
| 2246 return isolate->heap()->nan_value(); | 2246 return isolate->heap()->nan_value(); |
| 2247 } | 2247 } |
| 2248 | 2248 |
| 2249 return Smi::FromInt(subject->Get(i)); | 2249 return Smi::FromInt(subject->Get(i)); |
| 2250 } | 2250 } |
| 2251 | 2251 |
| 2252 | 2252 |
| 2253 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { | 2253 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { |
| 2254 NoHandleAllocation ha; | 2254 NoHandleAllocation ha(isolate); |
| 2255 ASSERT(args.length() == 1); | 2255 ASSERT(args.length() == 1); |
| 2256 return CharFromCode(isolate, args[0]); | 2256 return CharFromCode(isolate, args[0]); |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 | 2259 |
| 2260 class FixedArrayBuilder { | 2260 class FixedArrayBuilder { |
| 2261 public: | 2261 public: |
| 2262 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) | 2262 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) |
| 2263 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), | 2263 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), |
| 2264 length_(0), | 2264 length_(0), |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3470 pat_vector, | 3470 pat_vector, |
| 3471 start_index); | 3471 start_index); |
| 3472 } | 3472 } |
| 3473 } | 3473 } |
| 3474 | 3474 |
| 3475 return Smi::FromInt(position); | 3475 return Smi::FromInt(position); |
| 3476 } | 3476 } |
| 3477 | 3477 |
| 3478 | 3478 |
| 3479 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { | 3479 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { |
| 3480 NoHandleAllocation ha; | 3480 NoHandleAllocation ha(isolate); |
| 3481 ASSERT(args.length() == 2); | 3481 ASSERT(args.length() == 2); |
| 3482 | 3482 |
| 3483 CONVERT_ARG_CHECKED(String, str1, 0); | 3483 CONVERT_ARG_CHECKED(String, str1, 0); |
| 3484 CONVERT_ARG_CHECKED(String, str2, 1); | 3484 CONVERT_ARG_CHECKED(String, str2, 1); |
| 3485 | 3485 |
| 3486 if (str1 == str2) return Smi::FromInt(0); // Equal. | 3486 if (str1 == str2) return Smi::FromInt(0); // Equal. |
| 3487 int str1_length = str1->length(); | 3487 int str1_length = str1->length(); |
| 3488 int str2_length = str2->length(); | 3488 int str2_length = str2->length(); |
| 3489 | 3489 |
| 3490 // Decide trivial cases without flattening. | 3490 // Decide trivial cases without flattening. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 3518 uint16_t char1 = stream1.GetNext(); | 3518 uint16_t char1 = stream1.GetNext(); |
| 3519 uint16_t char2 = stream2.GetNext(); | 3519 uint16_t char2 = stream2.GetNext(); |
| 3520 if (char1 != char2) return Smi::FromInt(char1 - char2); | 3520 if (char1 != char2) return Smi::FromInt(char1 - char2); |
| 3521 } | 3521 } |
| 3522 | 3522 |
| 3523 return Smi::FromInt(str1_length - str2_length); | 3523 return Smi::FromInt(str1_length - str2_length); |
| 3524 } | 3524 } |
| 3525 | 3525 |
| 3526 | 3526 |
| 3527 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { | 3527 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { |
| 3528 NoHandleAllocation ha; | 3528 NoHandleAllocation ha(isolate); |
| 3529 ASSERT(args.length() == 3); | 3529 ASSERT(args.length() == 3); |
| 3530 | 3530 |
| 3531 CONVERT_ARG_CHECKED(String, value, 0); | 3531 CONVERT_ARG_CHECKED(String, value, 0); |
| 3532 int start, end; | 3532 int start, end; |
| 3533 // We have a fast integer-only case here to avoid a conversion to double in | 3533 // We have a fast integer-only case here to avoid a conversion to double in |
| 3534 // the common case where from and to are Smis. | 3534 // the common case where from and to are Smis. |
| 3535 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 3535 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
| 3536 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 3536 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
| 3537 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 3537 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
| 3538 start = from_number; | 3538 start = from_number; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3621 int capture_count = regexp->CaptureCount(); | 3621 int capture_count = regexp->CaptureCount(); |
| 3622 int subject_length = subject->length(); | 3622 int subject_length = subject->length(); |
| 3623 | 3623 |
| 3624 static const int kMinLengthToCache = 0x1000; | 3624 static const int kMinLengthToCache = 0x1000; |
| 3625 | 3625 |
| 3626 if (subject_length > kMinLengthToCache) { | 3626 if (subject_length > kMinLengthToCache) { |
| 3627 Handle<Object> cached_answer(RegExpResultsCache::Lookup( | 3627 Handle<Object> cached_answer(RegExpResultsCache::Lookup( |
| 3628 isolate->heap(), | 3628 isolate->heap(), |
| 3629 *subject, | 3629 *subject, |
| 3630 regexp->data(), | 3630 regexp->data(), |
| 3631 RegExpResultsCache::REGEXP_MULTIPLE_INDICES)); | 3631 RegExpResultsCache::REGEXP_MULTIPLE_INDICES), isolate); |
| 3632 if (*cached_answer != Smi::FromInt(0)) { | 3632 if (*cached_answer != Smi::FromInt(0)) { |
| 3633 Handle<FixedArray> cached_fixed_array = | 3633 Handle<FixedArray> cached_fixed_array = |
| 3634 Handle<FixedArray>(FixedArray::cast(*cached_answer)); | 3634 Handle<FixedArray>(FixedArray::cast(*cached_answer)); |
| 3635 // The cache FixedArray is a COW-array and can therefore be reused. | 3635 // The cache FixedArray is a COW-array and can therefore be reused. |
| 3636 isolate->factory()->SetContent(result_array, cached_fixed_array); | 3636 isolate->factory()->SetContent(result_array, cached_fixed_array); |
| 3637 // The actual length of the result array is stored in the last element of | 3637 // The actual length of the result array is stored in the last element of |
| 3638 // the backing store (the backing FixedArray may have a larger capacity). | 3638 // the backing store (the backing FixedArray may have a larger capacity). |
| 3639 Object* cached_fixed_array_last_element = | 3639 Object* cached_fixed_array_last_element = |
| 3640 cached_fixed_array->get(cached_fixed_array->length() - 1); | 3640 cached_fixed_array->get(cached_fixed_array->length() - 1); |
| 3641 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); | 3641 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3777 return SearchRegExpMultiple<false>( | 3777 return SearchRegExpMultiple<false>( |
| 3778 isolate, subject, regexp, last_match_info, result_array); | 3778 isolate, subject, regexp, last_match_info, result_array); |
| 3779 } else { | 3779 } else { |
| 3780 return SearchRegExpMultiple<true>( | 3780 return SearchRegExpMultiple<true>( |
| 3781 isolate, subject, regexp, last_match_info, result_array); | 3781 isolate, subject, regexp, last_match_info, result_array); |
| 3782 } | 3782 } |
| 3783 } | 3783 } |
| 3784 | 3784 |
| 3785 | 3785 |
| 3786 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { | 3786 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { |
| 3787 NoHandleAllocation ha; | 3787 NoHandleAllocation ha(isolate); |
| 3788 ASSERT(args.length() == 2); | 3788 ASSERT(args.length() == 2); |
| 3789 CONVERT_SMI_ARG_CHECKED(radix, 1); | 3789 CONVERT_SMI_ARG_CHECKED(radix, 1); |
| 3790 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 3790 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
| 3791 | 3791 |
| 3792 // Fast case where the result is a one character string. | 3792 // Fast case where the result is a one character string. |
| 3793 if (args[0]->IsSmi()) { | 3793 if (args[0]->IsSmi()) { |
| 3794 int value = args.smi_at(0); | 3794 int value = args.smi_at(0); |
| 3795 if (value >= 0 && value < radix) { | 3795 if (value >= 0 && value < radix) { |
| 3796 // Character array used for conversion. | 3796 // Character array used for conversion. |
| 3797 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; | 3797 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3813 } | 3813 } |
| 3814 char* str = DoubleToRadixCString(value, radix); | 3814 char* str = DoubleToRadixCString(value, radix); |
| 3815 MaybeObject* result = | 3815 MaybeObject* result = |
| 3816 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3816 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 3817 DeleteArray(str); | 3817 DeleteArray(str); |
| 3818 return result; | 3818 return result; |
| 3819 } | 3819 } |
| 3820 | 3820 |
| 3821 | 3821 |
| 3822 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 3822 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { |
| 3823 NoHandleAllocation ha; | 3823 NoHandleAllocation ha(isolate); |
| 3824 ASSERT(args.length() == 2); | 3824 ASSERT(args.length() == 2); |
| 3825 | 3825 |
| 3826 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 3826 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 3827 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 3827 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 3828 int f = FastD2IChecked(f_number); | 3828 int f = FastD2IChecked(f_number); |
| 3829 RUNTIME_ASSERT(f >= 0); | 3829 RUNTIME_ASSERT(f >= 0); |
| 3830 char* str = DoubleToFixedCString(value, f); | 3830 char* str = DoubleToFixedCString(value, f); |
| 3831 MaybeObject* res = | 3831 MaybeObject* res = |
| 3832 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3832 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 3833 DeleteArray(str); | 3833 DeleteArray(str); |
| 3834 return res; | 3834 return res; |
| 3835 } | 3835 } |
| 3836 | 3836 |
| 3837 | 3837 |
| 3838 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 3838 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
| 3839 NoHandleAllocation ha; | 3839 NoHandleAllocation ha(isolate); |
| 3840 ASSERT(args.length() == 2); | 3840 ASSERT(args.length() == 2); |
| 3841 | 3841 |
| 3842 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 3842 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 3843 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 3843 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 3844 int f = FastD2IChecked(f_number); | 3844 int f = FastD2IChecked(f_number); |
| 3845 RUNTIME_ASSERT(f >= -1 && f <= 20); | 3845 RUNTIME_ASSERT(f >= -1 && f <= 20); |
| 3846 char* str = DoubleToExponentialCString(value, f); | 3846 char* str = DoubleToExponentialCString(value, f); |
| 3847 MaybeObject* res = | 3847 MaybeObject* res = |
| 3848 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3848 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 3849 DeleteArray(str); | 3849 DeleteArray(str); |
| 3850 return res; | 3850 return res; |
| 3851 } | 3851 } |
| 3852 | 3852 |
| 3853 | 3853 |
| 3854 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 3854 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
| 3855 NoHandleAllocation ha; | 3855 NoHandleAllocation ha(isolate); |
| 3856 ASSERT(args.length() == 2); | 3856 ASSERT(args.length() == 2); |
| 3857 | 3857 |
| 3858 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 3858 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 3859 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 3859 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 3860 int f = FastD2IChecked(f_number); | 3860 int f = FastD2IChecked(f_number); |
| 3861 RUNTIME_ASSERT(f >= 1 && f <= 21); | 3861 RUNTIME_ASSERT(f >= 1 && f <= 21); |
| 3862 char* str = DoubleToPrecisionCString(value, f); | 3862 char* str = DoubleToPrecisionCString(value, f); |
| 3863 MaybeObject* res = | 3863 MaybeObject* res = |
| 3864 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 3864 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 3865 DeleteArray(str); | 3865 DeleteArray(str); |
| 3866 return res; | 3866 return res; |
| 3867 } | 3867 } |
| 3868 | 3868 |
| 3869 | 3869 |
| 3870 // Returns a single character string where first character equals | 3870 // Returns a single character string where first character equals |
| 3871 // string->Get(index). | 3871 // string->Get(index). |
| 3872 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { | 3872 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { |
| 3873 if (index < static_cast<uint32_t>(string->length())) { | 3873 if (index < static_cast<uint32_t>(string->length())) { |
| 3874 string->TryFlatten(); | 3874 string->TryFlatten(); |
| 3875 return LookupSingleCharacterStringFromCode( | 3875 return LookupSingleCharacterStringFromCode( |
| 3876 string->GetIsolate(), | |
| 3876 string->Get(index)); | 3877 string->Get(index)); |
| 3877 } | 3878 } |
| 3878 return Execution::CharAt(string, index); | 3879 return Execution::CharAt(string, index); |
| 3879 } | 3880 } |
| 3880 | 3881 |
| 3881 | 3882 |
| 3882 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate, | 3883 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate, |
| 3883 Handle<Object> object, | 3884 Handle<Object> object, |
| 3884 uint32_t index) { | 3885 uint32_t index) { |
| 3885 // Handle [] indexing on Strings | 3886 // Handle [] indexing on Strings |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3939 // the element if so. | 3940 // the element if so. |
| 3940 if (name->AsArrayIndex(&index)) { | 3941 if (name->AsArrayIndex(&index)) { |
| 3941 return GetElementOrCharAt(isolate, object, index); | 3942 return GetElementOrCharAt(isolate, object, index); |
| 3942 } else { | 3943 } else { |
| 3943 return object->GetProperty(*name); | 3944 return object->GetProperty(*name); |
| 3944 } | 3945 } |
| 3945 } | 3946 } |
| 3946 | 3947 |
| 3947 | 3948 |
| 3948 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 3949 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
| 3949 NoHandleAllocation ha; | 3950 NoHandleAllocation ha(isolate); |
| 3950 ASSERT(args.length() == 2); | 3951 ASSERT(args.length() == 2); |
| 3951 | 3952 |
| 3952 Handle<Object> object = args.at<Object>(0); | 3953 Handle<Object> object = args.at<Object>(0); |
| 3953 Handle<Object> key = args.at<Object>(1); | 3954 Handle<Object> key = args.at<Object>(1); |
| 3954 | 3955 |
| 3955 return Runtime::GetObjectProperty(isolate, object, key); | 3956 return Runtime::GetObjectProperty(isolate, object, key); |
| 3956 } | 3957 } |
| 3957 | 3958 |
| 3958 | 3959 |
| 3959 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. | 3960 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. |
| 3960 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 3961 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
| 3961 NoHandleAllocation ha; | 3962 NoHandleAllocation ha(isolate); |
| 3962 ASSERT(args.length() == 2); | 3963 ASSERT(args.length() == 2); |
| 3963 | 3964 |
| 3964 // Fast cases for getting named properties of the receiver JSObject | 3965 // Fast cases for getting named properties of the receiver JSObject |
| 3965 // itself. | 3966 // itself. |
| 3966 // | 3967 // |
| 3967 // The global proxy objects has to be excluded since LocalLookup on | 3968 // The global proxy objects has to be excluded since LocalLookup on |
| 3968 // the global proxy object can return a valid result even though the | 3969 // the global proxy object can return a valid result even though the |
| 3969 // global proxy object never has properties. This is the case | 3970 // global proxy object never has properties. This is the case |
| 3970 // because the global proxy object forwards everything to its hidden | 3971 // because the global proxy object forwards everything to its hidden |
| 3971 // prototype including local lookups. | 3972 // prototype including local lookups. |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4352 if (has_pending_exception) return Failure::Exception(); | 4353 if (has_pending_exception) return Failure::Exception(); |
| 4353 key_string = Handle<String>::cast(converted); | 4354 key_string = Handle<String>::cast(converted); |
| 4354 } | 4355 } |
| 4355 | 4356 |
| 4356 key_string->TryFlatten(); | 4357 key_string->TryFlatten(); |
| 4357 return receiver->DeleteProperty(*key_string, JSReceiver::FORCE_DELETION); | 4358 return receiver->DeleteProperty(*key_string, JSReceiver::FORCE_DELETION); |
| 4358 } | 4359 } |
| 4359 | 4360 |
| 4360 | 4361 |
| 4361 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 4362 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
| 4362 NoHandleAllocation ha; | 4363 NoHandleAllocation ha(isolate); |
| 4363 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 4364 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
| 4364 | 4365 |
| 4365 Handle<Object> object = args.at<Object>(0); | 4366 Handle<Object> object = args.at<Object>(0); |
| 4366 Handle<Object> key = args.at<Object>(1); | 4367 Handle<Object> key = args.at<Object>(1); |
| 4367 Handle<Object> value = args.at<Object>(2); | 4368 Handle<Object> value = args.at<Object>(2); |
| 4368 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 4369 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
| 4369 RUNTIME_ASSERT( | 4370 RUNTIME_ASSERT( |
| 4370 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4371 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 4371 // Compute attributes. | 4372 // Compute attributes. |
| 4372 PropertyAttributes attributes = | 4373 PropertyAttributes attributes = |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4391 HandleScope scope(isolate); | 4392 HandleScope scope(isolate); |
| 4392 RUNTIME_ASSERT(args.length() == 2); | 4393 RUNTIME_ASSERT(args.length() == 2); |
| 4393 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 4394 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 4394 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 4395 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
| 4395 JSObject::TransitionElementsKind(array, map->elements_kind()); | 4396 JSObject::TransitionElementsKind(array, map->elements_kind()); |
| 4396 return *array; | 4397 return *array; |
| 4397 } | 4398 } |
| 4398 | 4399 |
| 4399 | 4400 |
| 4400 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { | 4401 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { |
| 4401 NoHandleAllocation ha; | 4402 NoHandleAllocation ha(isolate); |
| 4402 RUNTIME_ASSERT(args.length() == 1); | 4403 RUNTIME_ASSERT(args.length() == 1); |
| 4403 Handle<Object> object = args.at<Object>(0); | 4404 Handle<Object> object = args.at<Object>(0); |
| 4404 if (object->IsJSObject()) { | 4405 if (object->IsJSObject()) { |
| 4405 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | 4406 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); |
| 4406 ASSERT(!js_object->map()->is_observed()); | 4407 ASSERT(!js_object->map()->is_observed()); |
| 4407 ElementsKind new_kind = js_object->HasFastHoleyElements() | 4408 ElementsKind new_kind = js_object->HasFastHoleyElements() |
| 4408 ? FAST_HOLEY_DOUBLE_ELEMENTS | 4409 ? FAST_HOLEY_DOUBLE_ELEMENTS |
| 4409 : FAST_DOUBLE_ELEMENTS; | 4410 : FAST_DOUBLE_ELEMENTS; |
| 4410 return TransitionElements(object, new_kind, isolate); | 4411 return TransitionElements(object, new_kind, isolate); |
| 4411 } else { | 4412 } else { |
| 4412 return *object; | 4413 return *object; |
| 4413 } | 4414 } |
| 4414 } | 4415 } |
| 4415 | 4416 |
| 4416 | 4417 |
| 4417 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { | 4418 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { |
| 4418 NoHandleAllocation ha; | 4419 NoHandleAllocation ha(isolate); |
| 4419 RUNTIME_ASSERT(args.length() == 1); | 4420 RUNTIME_ASSERT(args.length() == 1); |
| 4420 Handle<Object> object = args.at<Object>(0); | 4421 Handle<Object> object = args.at<Object>(0); |
| 4421 if (object->IsJSObject()) { | 4422 if (object->IsJSObject()) { |
| 4422 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | 4423 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); |
| 4423 ASSERT(!js_object->map()->is_observed()); | 4424 ASSERT(!js_object->map()->is_observed()); |
| 4424 ElementsKind new_kind = js_object->HasFastHoleyElements() | 4425 ElementsKind new_kind = js_object->HasFastHoleyElements() |
| 4425 ? FAST_HOLEY_ELEMENTS | 4426 ? FAST_HOLEY_ELEMENTS |
| 4426 : FAST_ELEMENTS; | 4427 : FAST_ELEMENTS; |
| 4427 return TransitionElements(object, new_kind, isolate); | 4428 return TransitionElements(object, new_kind, isolate); |
| 4428 } else { | 4429 } else { |
| 4429 return *object; | 4430 return *object; |
| 4430 } | 4431 } |
| 4431 } | 4432 } |
| 4432 | 4433 |
| 4433 | 4434 |
| 4434 // Set the native flag on the function. | 4435 // Set the native flag on the function. |
| 4435 // This is used to decide if we should transform null and undefined | 4436 // This is used to decide if we should transform null and undefined |
| 4436 // into the global object when doing call and apply. | 4437 // into the global object when doing call and apply. |
| 4437 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 4438 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { |
| 4438 NoHandleAllocation ha; | 4439 NoHandleAllocation ha(isolate); |
| 4439 RUNTIME_ASSERT(args.length() == 1); | 4440 RUNTIME_ASSERT(args.length() == 1); |
| 4440 | 4441 |
| 4441 Handle<Object> object = args.at<Object>(0); | 4442 Handle<Object> object = args.at<Object>(0); |
| 4442 | 4443 |
| 4443 if (object->IsJSFunction()) { | 4444 if (object->IsJSFunction()) { |
| 4444 JSFunction* func = JSFunction::cast(*object); | 4445 JSFunction* func = JSFunction::cast(*object); |
| 4445 func->shared()->set_native(true); | 4446 func->shared()->set_native(true); |
| 4446 } | 4447 } |
| 4447 return isolate->heap()->undefined_value(); | 4448 return isolate->heap()->undefined_value(); |
| 4448 } | 4449 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4531 debug->ClearStepOut(); | 4532 debug->ClearStepOut(); |
| 4532 debug->FloodWithOneShot(callback); | 4533 debug->FloodWithOneShot(callback); |
| 4533 #endif // ENABLE_DEBUGGER_SUPPORT | 4534 #endif // ENABLE_DEBUGGER_SUPPORT |
| 4534 return isolate->heap()->undefined_value(); | 4535 return isolate->heap()->undefined_value(); |
| 4535 } | 4536 } |
| 4536 | 4537 |
| 4537 | 4538 |
| 4538 // Set a local property, even if it is READ_ONLY. If the property does not | 4539 // Set a local property, even if it is READ_ONLY. If the property does not |
| 4539 // exist, it will be added with attributes NONE. | 4540 // exist, it will be added with attributes NONE. |
| 4540 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { | 4541 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { |
| 4541 NoHandleAllocation ha; | 4542 NoHandleAllocation ha(isolate); |
| 4542 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 4543 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
| 4543 CONVERT_ARG_CHECKED(JSObject, object, 0); | 4544 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 4544 CONVERT_ARG_CHECKED(String, name, 1); | 4545 CONVERT_ARG_CHECKED(String, name, 1); |
| 4545 // Compute attributes. | 4546 // Compute attributes. |
| 4546 PropertyAttributes attributes = NONE; | 4547 PropertyAttributes attributes = NONE; |
| 4547 if (args.length() == 4) { | 4548 if (args.length() == 4) { |
| 4548 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); | 4549 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
| 4549 // Only attribute bits should be set. | 4550 // Only attribute bits should be set. |
| 4550 RUNTIME_ASSERT( | 4551 RUNTIME_ASSERT( |
| 4551 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4552 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 4552 attributes = static_cast<PropertyAttributes>(unchecked_value); | 4553 attributes = static_cast<PropertyAttributes>(unchecked_value); |
| 4553 } | 4554 } |
| 4554 | 4555 |
| 4555 return object-> | 4556 return object-> |
| 4556 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 4557 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
| 4557 } | 4558 } |
| 4558 | 4559 |
| 4559 | 4560 |
| 4560 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 4561 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
| 4561 NoHandleAllocation ha; | 4562 NoHandleAllocation ha(isolate); |
| 4562 ASSERT(args.length() == 3); | 4563 ASSERT(args.length() == 3); |
| 4563 | 4564 |
| 4564 CONVERT_ARG_CHECKED(JSReceiver, object, 0); | 4565 CONVERT_ARG_CHECKED(JSReceiver, object, 0); |
| 4565 CONVERT_ARG_CHECKED(String, key, 1); | 4566 CONVERT_ARG_CHECKED(String, key, 1); |
| 4566 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 4567 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
| 4567 return object->DeleteProperty(key, (strict_mode == kStrictMode) | 4568 return object->DeleteProperty(key, (strict_mode == kStrictMode) |
| 4568 ? JSReceiver::STRICT_DELETION | 4569 ? JSReceiver::STRICT_DELETION |
| 4569 : JSReceiver::NORMAL_DELETION); | 4570 : JSReceiver::NORMAL_DELETION); |
| 4570 } | 4571 } |
| 4571 | 4572 |
| 4572 | 4573 |
| 4573 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 4574 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
| 4574 Handle<JSObject> object, | 4575 Handle<JSObject> object, |
| 4575 Handle<String> key) { | 4576 Handle<String> key) { |
| 4576 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 4577 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
| 4577 // Handle hidden prototypes. If there's a hidden prototype above this thing | 4578 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| 4578 // then we have to check it for properties, because they are supposed to | 4579 // then we have to check it for properties, because they are supposed to |
| 4579 // look like they are on this object. | 4580 // look like they are on this object. |
| 4580 Handle<Object> proto(object->GetPrototype()); | 4581 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4581 if (proto->IsJSObject() && | 4582 if (proto->IsJSObject() && |
| 4582 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 4583 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
| 4583 return HasLocalPropertyImplementation(isolate, | 4584 return HasLocalPropertyImplementation(isolate, |
| 4584 Handle<JSObject>::cast(proto), | 4585 Handle<JSObject>::cast(proto), |
| 4585 key); | 4586 key); |
| 4586 } | 4587 } |
| 4587 return isolate->heap()->false_value(); | 4588 return isolate->heap()->false_value(); |
| 4588 } | 4589 } |
| 4589 | 4590 |
| 4590 | 4591 |
| 4591 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 4592 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { |
| 4592 NoHandleAllocation ha; | 4593 NoHandleAllocation ha(isolate); |
| 4593 ASSERT(args.length() == 2); | 4594 ASSERT(args.length() == 2); |
| 4594 CONVERT_ARG_CHECKED(String, key, 1); | 4595 CONVERT_ARG_CHECKED(String, key, 1); |
| 4595 | 4596 |
| 4596 uint32_t index; | 4597 uint32_t index; |
| 4597 const bool key_is_array_index = key->AsArrayIndex(&index); | 4598 const bool key_is_array_index = key->AsArrayIndex(&index); |
| 4598 | 4599 |
| 4599 Object* obj = args[0]; | 4600 Object* obj = args[0]; |
| 4600 // Only JS objects can have properties. | 4601 // Only JS objects can have properties. |
| 4601 if (obj->IsJSObject()) { | 4602 if (obj->IsJSObject()) { |
| 4602 JSObject* object = JSObject::cast(obj); | 4603 JSObject* object = JSObject::cast(obj); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 4620 String* string = String::cast(obj); | 4621 String* string = String::cast(obj); |
| 4621 if (index < static_cast<uint32_t>(string->length())) { | 4622 if (index < static_cast<uint32_t>(string->length())) { |
| 4622 return isolate->heap()->true_value(); | 4623 return isolate->heap()->true_value(); |
| 4623 } | 4624 } |
| 4624 } | 4625 } |
| 4625 return isolate->heap()->false_value(); | 4626 return isolate->heap()->false_value(); |
| 4626 } | 4627 } |
| 4627 | 4628 |
| 4628 | 4629 |
| 4629 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 4630 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { |
| 4630 NoHandleAllocation na; | 4631 NoHandleAllocation na(isolate); |
| 4631 ASSERT(args.length() == 2); | 4632 ASSERT(args.length() == 2); |
| 4632 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 4633 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
| 4633 CONVERT_ARG_CHECKED(String, key, 1); | 4634 CONVERT_ARG_CHECKED(String, key, 1); |
| 4634 | 4635 |
| 4635 bool result = receiver->HasProperty(key); | 4636 bool result = receiver->HasProperty(key); |
| 4636 if (isolate->has_pending_exception()) return Failure::Exception(); | 4637 if (isolate->has_pending_exception()) return Failure::Exception(); |
| 4637 return isolate->heap()->ToBoolean(result); | 4638 return isolate->heap()->ToBoolean(result); |
| 4638 } | 4639 } |
| 4639 | 4640 |
| 4640 | 4641 |
| 4641 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 4642 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { |
| 4642 NoHandleAllocation na; | 4643 NoHandleAllocation na(isolate); |
| 4643 ASSERT(args.length() == 2); | 4644 ASSERT(args.length() == 2); |
| 4644 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 4645 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
| 4645 CONVERT_SMI_ARG_CHECKED(index, 1); | 4646 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 4646 | 4647 |
| 4647 bool result = receiver->HasElement(index); | 4648 bool result = receiver->HasElement(index); |
| 4648 if (isolate->has_pending_exception()) return Failure::Exception(); | 4649 if (isolate->has_pending_exception()) return Failure::Exception(); |
| 4649 return isolate->heap()->ToBoolean(result); | 4650 return isolate->heap()->ToBoolean(result); |
| 4650 } | 4651 } |
| 4651 | 4652 |
| 4652 | 4653 |
| 4653 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { | 4654 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { |
| 4654 NoHandleAllocation ha; | 4655 NoHandleAllocation ha(isolate); |
| 4655 ASSERT(args.length() == 2); | 4656 ASSERT(args.length() == 2); |
| 4656 | 4657 |
| 4657 CONVERT_ARG_CHECKED(JSObject, object, 0); | 4658 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 4658 CONVERT_ARG_CHECKED(String, key, 1); | 4659 CONVERT_ARG_CHECKED(String, key, 1); |
| 4659 | 4660 |
| 4660 PropertyAttributes att = object->GetLocalPropertyAttribute(key); | 4661 PropertyAttributes att = object->GetLocalPropertyAttribute(key); |
| 4661 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); | 4662 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); |
| 4662 } | 4663 } |
| 4663 | 4664 |
| 4664 | 4665 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4874 | 4875 |
| 4875 if (object->IsJSGlobalProxy()) { | 4876 if (object->IsJSGlobalProxy()) { |
| 4876 // Do access checks before going to the global object. | 4877 // Do access checks before going to the global object. |
| 4877 if (object->IsAccessCheckNeeded() && | 4878 if (object->IsAccessCheckNeeded() && |
| 4878 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), | 4879 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), |
| 4879 v8::ACCESS_KEYS)) { | 4880 v8::ACCESS_KEYS)) { |
| 4880 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 4881 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); |
| 4881 return *isolate->factory()->NewJSArray(0); | 4882 return *isolate->factory()->NewJSArray(0); |
| 4882 } | 4883 } |
| 4883 | 4884 |
| 4884 Handle<Object> proto(object->GetPrototype()); | 4885 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4885 // If proxy is detached we simply return an empty array. | 4886 // If proxy is detached we simply return an empty array. |
| 4886 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); | 4887 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); |
| 4887 object = Handle<JSObject>::cast(proto); | 4888 object = Handle<JSObject>::cast(proto); |
| 4888 } | 4889 } |
| 4889 | 4890 |
| 4890 bool threw = false; | 4891 bool threw = false; |
| 4891 Handle<FixedArray> contents = | 4892 Handle<FixedArray> contents = |
| 4892 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &threw); | 4893 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &threw); |
| 4893 if (threw) return Failure::Exception(); | 4894 if (threw) return Failure::Exception(); |
| 4894 | 4895 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 4908 Handle<Object> entry_str = | 4909 Handle<Object> entry_str = |
| 4909 isolate->factory()->NumberToString(entry_handle); | 4910 isolate->factory()->NumberToString(entry_handle); |
| 4910 copy->set(i, *entry_str); | 4911 copy->set(i, *entry_str); |
| 4911 } | 4912 } |
| 4912 } | 4913 } |
| 4913 return *isolate->factory()->NewJSArrayWithElements(copy); | 4914 return *isolate->factory()->NewJSArrayWithElements(copy); |
| 4914 } | 4915 } |
| 4915 | 4916 |
| 4916 | 4917 |
| 4917 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { | 4918 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { |
| 4918 NoHandleAllocation ha; | 4919 NoHandleAllocation ha(isolate); |
| 4919 ASSERT(args.length() == 1); | 4920 ASSERT(args.length() == 1); |
| 4920 | 4921 |
| 4921 // Compute the frame holding the arguments. | 4922 // Compute the frame holding the arguments. |
| 4922 JavaScriptFrameIterator it(isolate); | 4923 JavaScriptFrameIterator it(isolate); |
| 4923 it.AdvanceToArgumentsFrame(); | 4924 it.AdvanceToArgumentsFrame(); |
| 4924 JavaScriptFrame* frame = it.frame(); | 4925 JavaScriptFrame* frame = it.frame(); |
| 4925 | 4926 |
| 4926 // Get the actual number of provided arguments. | 4927 // Get the actual number of provided arguments. |
| 4927 const uint32_t n = frame->ComputeParametersCount(); | 4928 const uint32_t n = frame->ComputeParametersCount(); |
| 4928 | 4929 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4970 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 4971 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { |
| 4971 ASSERT(args.length() == 1); | 4972 ASSERT(args.length() == 1); |
| 4972 Object* object = args[0]; | 4973 Object* object = args[0]; |
| 4973 return (object->IsJSObject() && !object->IsGlobalObject()) | 4974 return (object->IsJSObject() && !object->IsGlobalObject()) |
| 4974 ? JSObject::cast(object)->TransformToFastProperties(0) | 4975 ? JSObject::cast(object)->TransformToFastProperties(0) |
| 4975 : object; | 4976 : object; |
| 4976 } | 4977 } |
| 4977 | 4978 |
| 4978 | 4979 |
| 4979 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 4980 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { |
| 4980 NoHandleAllocation ha; | 4981 NoHandleAllocation ha(isolate); |
| 4981 ASSERT(args.length() == 1); | 4982 ASSERT(args.length() == 1); |
| 4982 | 4983 |
| 4983 return args[0]->ToBoolean(); | 4984 return args[0]->ToBoolean(); |
| 4984 } | 4985 } |
| 4985 | 4986 |
| 4986 | 4987 |
| 4987 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 4988 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
| 4988 // Possible optimizations: put the type string into the oddballs. | 4989 // Possible optimizations: put the type string into the oddballs. |
| 4989 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { | 4990 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { |
| 4990 NoHandleAllocation ha; | 4991 NoHandleAllocation ha(isolate); |
| 4991 | 4992 |
| 4992 Object* obj = args[0]; | 4993 Object* obj = args[0]; |
| 4993 if (obj->IsNumber()) return isolate->heap()->number_symbol(); | 4994 if (obj->IsNumber()) return isolate->heap()->number_symbol(); |
| 4994 HeapObject* heap_obj = HeapObject::cast(obj); | 4995 HeapObject* heap_obj = HeapObject::cast(obj); |
| 4995 | 4996 |
| 4996 // typeof an undetectable object is 'undefined' | 4997 // typeof an undetectable object is 'undefined' |
| 4997 if (heap_obj->map()->is_undetectable()) { | 4998 if (heap_obj->map()->is_undetectable()) { |
| 4998 return isolate->heap()->undefined_symbol(); | 4999 return isolate->heap()->undefined_symbol(); |
| 4999 } | 5000 } |
| 5000 | 5001 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5042 | 5043 |
| 5043 for (int i = from + 1; i < to; i++) { | 5044 for (int i = from + 1; i < to; i++) { |
| 5044 d = 10 * d + (s[i] - '0'); | 5045 d = 10 * d + (s[i] - '0'); |
| 5045 } | 5046 } |
| 5046 | 5047 |
| 5047 return d; | 5048 return d; |
| 5048 } | 5049 } |
| 5049 | 5050 |
| 5050 | 5051 |
| 5051 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { | 5052 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { |
| 5052 NoHandleAllocation ha; | 5053 NoHandleAllocation ha(isolate); |
| 5053 ASSERT(args.length() == 1); | 5054 ASSERT(args.length() == 1); |
| 5054 CONVERT_ARG_CHECKED(String, subject, 0); | 5055 CONVERT_ARG_CHECKED(String, subject, 0); |
| 5055 subject->TryFlatten(); | 5056 subject->TryFlatten(); |
| 5056 | 5057 |
| 5057 // Fast case: short integer or some sorts of junk values. | 5058 // Fast case: short integer or some sorts of junk values. |
| 5058 int len = subject->length(); | 5059 int len = subject->length(); |
| 5059 if (subject->IsSeqOneByteString()) { | 5060 if (subject->IsSeqOneByteString()) { |
| 5060 if (len == 0) return Smi::FromInt(0); | 5061 if (len == 0) return Smi::FromInt(0); |
| 5061 | 5062 |
| 5062 uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); | 5063 uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 5155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 5155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 5156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 5156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 5157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 5157 }; | 5158 }; |
| 5158 return kNotEscaped[character] != 0; | 5159 return kNotEscaped[character] != 0; |
| 5159 } | 5160 } |
| 5160 | 5161 |
| 5161 | 5162 |
| 5162 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { | 5163 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { |
| 5163 const char hex_chars[] = "0123456789ABCDEF"; | 5164 const char hex_chars[] = "0123456789ABCDEF"; |
| 5164 NoHandleAllocation ha; | 5165 NoHandleAllocation ha(isolate); |
| 5165 ASSERT(args.length() == 1); | 5166 ASSERT(args.length() == 1); |
| 5166 CONVERT_ARG_CHECKED(String, source, 0); | 5167 CONVERT_ARG_CHECKED(String, source, 0); |
| 5167 | 5168 |
| 5168 source->TryFlatten(); | 5169 source->TryFlatten(); |
| 5169 | 5170 |
| 5170 int escaped_length = 0; | 5171 int escaped_length = 0; |
| 5171 int length = source->length(); | 5172 int length = source->length(); |
| 5172 { | 5173 { |
| 5173 Access<ConsStringIteratorOp> op( | 5174 Access<ConsStringIteratorOp> op( |
| 5174 isolate->runtime_state()->string_iterator()); | 5175 isolate->runtime_state()->string_iterator()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5272 *step = 3; | 5273 *step = 3; |
| 5273 return lo; | 5274 return lo; |
| 5274 } else { | 5275 } else { |
| 5275 *step = 1; | 5276 *step = 1; |
| 5276 return character; | 5277 return character; |
| 5277 } | 5278 } |
| 5278 } | 5279 } |
| 5279 | 5280 |
| 5280 | 5281 |
| 5281 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { | 5282 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { |
| 5282 NoHandleAllocation ha; | 5283 NoHandleAllocation ha(isolate); |
| 5283 ASSERT(args.length() == 1); | 5284 ASSERT(args.length() == 1); |
| 5284 CONVERT_ARG_CHECKED(String, source, 0); | 5285 CONVERT_ARG_CHECKED(String, source, 0); |
| 5285 | 5286 |
| 5286 source->TryFlatten(); | 5287 source->TryFlatten(); |
| 5287 | 5288 |
| 5288 bool one_byte = true; | 5289 bool one_byte = true; |
| 5289 int length = source->length(); | 5290 int length = source->length(); |
| 5290 | 5291 |
| 5291 int unescaped_length = 0; | 5292 int unescaped_length = 0; |
| 5292 for (int i = 0; i < length; unescaped_length++) { | 5293 for (int i = 0; i < length; unescaped_length++) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5530 write_cursor - reinterpret_cast<Char*>( | 5531 write_cursor - reinterpret_cast<Char*>( |
| 5531 new_string->address() + SeqString::kHeaderSize)); | 5532 new_string->address() + SeqString::kHeaderSize)); |
| 5532 isolate->heap()->new_space()-> | 5533 isolate->heap()->new_space()-> |
| 5533 template ShrinkStringAtAllocationBoundary<StringType>( | 5534 template ShrinkStringAtAllocationBoundary<StringType>( |
| 5534 new_string, final_length); | 5535 new_string, final_length); |
| 5535 return new_string; | 5536 return new_string; |
| 5536 } | 5537 } |
| 5537 | 5538 |
| 5538 | 5539 |
| 5539 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { | 5540 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { |
| 5540 NoHandleAllocation ha; | 5541 NoHandleAllocation ha(isolate); |
| 5541 CONVERT_ARG_CHECKED(String, str, 0); | 5542 CONVERT_ARG_CHECKED(String, str, 0); |
| 5542 if (!str->IsFlat()) { | 5543 if (!str->IsFlat()) { |
| 5543 MaybeObject* try_flatten = str->TryFlatten(); | 5544 MaybeObject* try_flatten = str->TryFlatten(); |
| 5544 Object* flat; | 5545 Object* flat; |
| 5545 if (!try_flatten->ToObject(&flat)) { | 5546 if (!try_flatten->ToObject(&flat)) { |
| 5546 return try_flatten; | 5547 return try_flatten; |
| 5547 } | 5548 } |
| 5548 str = String::cast(flat); | 5549 str = String::cast(flat); |
| 5549 ASSERT(str->IsFlat()); | 5550 ASSERT(str->IsFlat()); |
| 5550 } | 5551 } |
| 5551 String::FlatContent flat = str->GetFlatContent(); | 5552 String::FlatContent flat = str->GetFlatContent(); |
| 5552 ASSERT(flat.IsFlat()); | 5553 ASSERT(flat.IsFlat()); |
| 5553 if (flat.IsTwoByte()) { | 5554 if (flat.IsTwoByte()) { |
| 5554 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, | 5555 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, |
| 5555 flat.ToUC16Vector()); | 5556 flat.ToUC16Vector()); |
| 5556 } else { | 5557 } else { |
| 5557 return QuoteJsonString<uint8_t, SeqOneByteString, false>( | 5558 return QuoteJsonString<uint8_t, SeqOneByteString, false>( |
| 5558 isolate, | 5559 isolate, |
| 5559 flat.ToOneByteVector()); | 5560 flat.ToOneByteVector()); |
| 5560 } | 5561 } |
| 5561 } | 5562 } |
| 5562 | 5563 |
| 5563 | 5564 |
| 5564 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { | 5565 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { |
| 5565 NoHandleAllocation ha; | 5566 NoHandleAllocation ha(isolate); |
| 5566 CONVERT_ARG_CHECKED(String, str, 0); | 5567 CONVERT_ARG_CHECKED(String, str, 0); |
| 5567 if (!str->IsFlat()) { | 5568 if (!str->IsFlat()) { |
| 5568 MaybeObject* try_flatten = str->TryFlatten(); | 5569 MaybeObject* try_flatten = str->TryFlatten(); |
| 5569 Object* flat; | 5570 Object* flat; |
| 5570 if (!try_flatten->ToObject(&flat)) { | 5571 if (!try_flatten->ToObject(&flat)) { |
| 5571 return try_flatten; | 5572 return try_flatten; |
| 5572 } | 5573 } |
| 5573 str = String::cast(flat); | 5574 str = String::cast(flat); |
| 5574 ASSERT(str->IsFlat()); | 5575 ASSERT(str->IsFlat()); |
| 5575 } | 5576 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5633 write_cursor - reinterpret_cast<Char*>( | 5634 write_cursor - reinterpret_cast<Char*>( |
| 5634 new_string->address() + SeqString::kHeaderSize)); | 5635 new_string->address() + SeqString::kHeaderSize)); |
| 5635 isolate->heap()->new_space()-> | 5636 isolate->heap()->new_space()-> |
| 5636 template ShrinkStringAtAllocationBoundary<StringType>( | 5637 template ShrinkStringAtAllocationBoundary<StringType>( |
| 5637 new_string, final_length); | 5638 new_string, final_length); |
| 5638 return new_string; | 5639 return new_string; |
| 5639 } | 5640 } |
| 5640 | 5641 |
| 5641 | 5642 |
| 5642 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { | 5643 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { |
| 5643 NoHandleAllocation ha; | 5644 NoHandleAllocation ha(isolate); |
| 5644 ASSERT(args.length() == 1); | 5645 ASSERT(args.length() == 1); |
| 5645 CONVERT_ARG_CHECKED(JSArray, array, 0); | 5646 CONVERT_ARG_CHECKED(JSArray, array, 0); |
| 5646 | 5647 |
| 5647 if (!array->HasFastObjectElements()) { | 5648 if (!array->HasFastObjectElements()) { |
| 5648 return isolate->heap()->undefined_value(); | 5649 return isolate->heap()->undefined_value(); |
| 5649 } | 5650 } |
| 5650 FixedArray* elements = FixedArray::cast(array->elements()); | 5651 FixedArray* elements = FixedArray::cast(array->elements()); |
| 5651 int n = elements->length(); | 5652 int n = elements->length(); |
| 5652 bool ascii = true; | 5653 bool ascii = true; |
| 5653 int total_length = 0; | 5654 int total_length = 0; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 5680 elements, | 5681 elements, |
| 5681 worst_case_length); | 5682 worst_case_length); |
| 5682 } | 5683 } |
| 5683 } | 5684 } |
| 5684 | 5685 |
| 5685 | 5686 |
| 5686 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { | 5687 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { |
| 5687 ASSERT(args.length() == 1); | 5688 ASSERT(args.length() == 1); |
| 5688 HandleScope scope(isolate); | 5689 HandleScope scope(isolate); |
| 5689 BasicJsonStringifier stringifier(isolate); | 5690 BasicJsonStringifier stringifier(isolate); |
| 5690 return stringifier.Stringify(Handle<Object>(args[0])); | 5691 return stringifier.Stringify(Handle<Object>(args[0], isolate)); |
| 5691 } | 5692 } |
| 5692 | 5693 |
| 5693 | 5694 |
| 5694 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 5695 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { |
| 5695 NoHandleAllocation ha; | 5696 NoHandleAllocation ha(isolate); |
| 5696 | 5697 |
| 5697 CONVERT_ARG_CHECKED(String, s, 0); | 5698 CONVERT_ARG_CHECKED(String, s, 0); |
| 5698 CONVERT_SMI_ARG_CHECKED(radix, 1); | 5699 CONVERT_SMI_ARG_CHECKED(radix, 1); |
| 5699 | 5700 |
| 5700 s->TryFlatten(); | 5701 s->TryFlatten(); |
| 5701 | 5702 |
| 5702 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 5703 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
| 5703 double value = StringToInt(isolate->unicode_cache(), s, radix); | 5704 double value = StringToInt(isolate->unicode_cache(), s, radix); |
| 5704 return isolate->heap()->NumberFromDouble(value); | 5705 return isolate->heap()->NumberFromDouble(value); |
| 5705 } | 5706 } |
| 5706 | 5707 |
| 5707 | 5708 |
| 5708 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 5709 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { |
| 5709 NoHandleAllocation ha; | 5710 NoHandleAllocation ha(isolate); |
| 5710 CONVERT_ARG_CHECKED(String, str, 0); | 5711 CONVERT_ARG_CHECKED(String, str, 0); |
| 5711 | 5712 |
| 5712 // ECMA-262 section 15.1.2.3, empty string is NaN | 5713 // ECMA-262 section 15.1.2.3, empty string is NaN |
| 5713 double value = StringToDouble(isolate->unicode_cache(), | 5714 double value = StringToDouble(isolate->unicode_cache(), |
| 5714 str, ALLOW_TRAILING_JUNK, OS::nan_value()); | 5715 str, ALLOW_TRAILING_JUNK, OS::nan_value()); |
| 5715 | 5716 |
| 5716 // Create a number object from the value. | 5717 // Create a number object from the value. |
| 5717 return isolate->heap()->NumberFromDouble(value); | 5718 return isolate->heap()->NumberFromDouble(value); |
| 5718 } | 5719 } |
| 5719 | 5720 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5979 }; | 5980 }; |
| 5980 | 5981 |
| 5981 } // namespace | 5982 } // namespace |
| 5982 | 5983 |
| 5983 | 5984 |
| 5984 template <typename ConvertTraits> | 5985 template <typename ConvertTraits> |
| 5985 MUST_USE_RESULT static MaybeObject* ConvertCase( | 5986 MUST_USE_RESULT static MaybeObject* ConvertCase( |
| 5986 Arguments args, | 5987 Arguments args, |
| 5987 Isolate* isolate, | 5988 Isolate* isolate, |
| 5988 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { | 5989 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { |
| 5989 NoHandleAllocation ha; | 5990 NoHandleAllocation ha(isolate); |
| 5990 CONVERT_ARG_CHECKED(String, s, 0); | 5991 CONVERT_ARG_CHECKED(String, s, 0); |
| 5991 s = s->TryFlattenGetString(); | 5992 s = s->TryFlattenGetString(); |
| 5992 | 5993 |
| 5993 const int length = s->length(); | 5994 const int length = s->length(); |
| 5994 // Assume that the string is not empty; we need this assumption later | 5995 // Assume that the string is not empty; we need this assumption later |
| 5995 if (length == 0) return s; | 5996 if (length == 0) return s; |
| 5996 | 5997 |
| 5997 // Simpler handling of ASCII strings. | 5998 // Simpler handling of ASCII strings. |
| 5998 // | 5999 // |
| 5999 // NOTE: This assumes that the upper/lower case of an ASCII | 6000 // NOTE: This assumes that the upper/lower case of an ASCII |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6054 args, isolate, isolate->runtime_state()->to_upper_mapping()); | 6055 args, isolate, isolate->runtime_state()->to_upper_mapping()); |
| 6055 } | 6056 } |
| 6056 | 6057 |
| 6057 | 6058 |
| 6058 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { | 6059 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { |
| 6059 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; | 6060 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; |
| 6060 } | 6061 } |
| 6061 | 6062 |
| 6062 | 6063 |
| 6063 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { | 6064 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { |
| 6064 NoHandleAllocation ha; | 6065 NoHandleAllocation ha(isolate); |
| 6065 ASSERT(args.length() == 3); | 6066 ASSERT(args.length() == 3); |
| 6066 | 6067 |
| 6067 CONVERT_ARG_CHECKED(String, s, 0); | 6068 CONVERT_ARG_CHECKED(String, s, 0); |
| 6068 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); | 6069 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); |
| 6069 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); | 6070 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); |
| 6070 | 6071 |
| 6071 s->TryFlatten(); | 6072 s->TryFlatten(); |
| 6072 int length = s->length(); | 6073 int length = s->length(); |
| 6073 | 6074 |
| 6074 int left = 0; | 6075 int left = 0; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 6093 HandleScope handle_scope(isolate); | 6094 HandleScope handle_scope(isolate); |
| 6094 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6095 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
| 6095 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 6096 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
| 6096 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); | 6097 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); |
| 6097 | 6098 |
| 6098 int subject_length = subject->length(); | 6099 int subject_length = subject->length(); |
| 6099 int pattern_length = pattern->length(); | 6100 int pattern_length = pattern->length(); |
| 6100 RUNTIME_ASSERT(pattern_length > 0); | 6101 RUNTIME_ASSERT(pattern_length > 0); |
| 6101 | 6102 |
| 6102 if (limit == 0xffffffffu) { | 6103 if (limit == 0xffffffffu) { |
| 6103 Handle<Object> cached_answer(RegExpResultsCache::Lookup( | 6104 Handle<Object> cached_answer( |
| 6104 isolate->heap(), | 6105 RegExpResultsCache::Lookup(isolate->heap(), |
| 6105 *subject, | 6106 *subject, |
| 6106 *pattern, | 6107 *pattern, |
| 6107 RegExpResultsCache::STRING_SPLIT_SUBSTRINGS)); | 6108 RegExpResultsCache::STRING_SPLIT_SUBSTRINGS), |
| 6109 isolate); | |
| 6108 if (*cached_answer != Smi::FromInt(0)) { | 6110 if (*cached_answer != Smi::FromInt(0)) { |
| 6109 // The cache FixedArray is a COW-array and can therefore be reused. | 6111 // The cache FixedArray is a COW-array and can therefore be reused. |
| 6110 Handle<JSArray> result = | 6112 Handle<JSArray> result = |
| 6111 isolate->factory()->NewJSArrayWithElements( | 6113 isolate->factory()->NewJSArrayWithElements( |
| 6112 Handle<FixedArray>::cast(cached_answer)); | 6114 Handle<FixedArray>::cast(cached_answer)); |
| 6113 return *result; | 6115 return *result; |
| 6114 } | 6116 } |
| 6115 } | 6117 } |
| 6116 | 6118 |
| 6117 // The limit can be very large (0xffffffffu), but since the pattern | 6119 // The limit can be very large (0xffffffffu), but since the pattern |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6243 length); | 6245 length); |
| 6244 } else { | 6246 } else { |
| 6245 MemsetPointer(elements->data_start(), | 6247 MemsetPointer(elements->data_start(), |
| 6246 isolate->heap()->undefined_value(), | 6248 isolate->heap()->undefined_value(), |
| 6247 length); | 6249 length); |
| 6248 } | 6250 } |
| 6249 } else { | 6251 } else { |
| 6250 elements = isolate->factory()->NewFixedArray(length); | 6252 elements = isolate->factory()->NewFixedArray(length); |
| 6251 } | 6253 } |
| 6252 for (int i = position; i < length; ++i) { | 6254 for (int i = position; i < length; ++i) { |
| 6253 Handle<Object> str = LookupSingleCharacterStringFromCode(s->Get(i)); | 6255 Handle<Object> str = |
| 6256 LookupSingleCharacterStringFromCode(isolate, s->Get(i)); | |
| 6254 elements->set(i, *str); | 6257 elements->set(i, *str); |
| 6255 } | 6258 } |
| 6256 | 6259 |
| 6257 #ifdef DEBUG | 6260 #ifdef DEBUG |
| 6258 for (int i = 0; i < length; ++i) { | 6261 for (int i = 0; i < length; ++i) { |
| 6259 ASSERT(String::cast(elements->get(i))->length() == 1); | 6262 ASSERT(String::cast(elements->get(i))->length() == 1); |
| 6260 } | 6263 } |
| 6261 #endif | 6264 #endif |
| 6262 | 6265 |
| 6263 return *isolate->factory()->NewJSArrayWithElements(elements); | 6266 return *isolate->factory()->NewJSArrayWithElements(elements); |
| 6264 } | 6267 } |
| 6265 | 6268 |
| 6266 | 6269 |
| 6267 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { | 6270 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { |
| 6268 NoHandleAllocation ha; | 6271 NoHandleAllocation ha(isolate); |
| 6269 ASSERT(args.length() == 1); | 6272 ASSERT(args.length() == 1); |
| 6270 CONVERT_ARG_CHECKED(String, value, 0); | 6273 CONVERT_ARG_CHECKED(String, value, 0); |
| 6271 return value->ToObject(); | 6274 return value->ToObject(); |
| 6272 } | 6275 } |
| 6273 | 6276 |
| 6274 | 6277 |
| 6275 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6278 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
| 6276 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6279 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
| 6277 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6280 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
| 6278 return char_length == 0; | 6281 return char_length == 0; |
| 6279 } | 6282 } |
| 6280 | 6283 |
| 6281 | 6284 |
| 6282 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { | 6285 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { |
| 6283 NoHandleAllocation ha; | 6286 NoHandleAllocation ha(isolate); |
| 6284 ASSERT(args.length() == 1); | 6287 ASSERT(args.length() == 1); |
| 6285 | 6288 |
| 6286 Object* number = args[0]; | 6289 Object* number = args[0]; |
| 6287 RUNTIME_ASSERT(number->IsNumber()); | 6290 RUNTIME_ASSERT(number->IsNumber()); |
| 6288 | 6291 |
| 6289 return isolate->heap()->NumberToString(number); | 6292 return isolate->heap()->NumberToString(number); |
| 6290 } | 6293 } |
| 6291 | 6294 |
| 6292 | 6295 |
| 6293 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { | 6296 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { |
| 6294 NoHandleAllocation ha; | 6297 NoHandleAllocation ha(isolate); |
| 6295 ASSERT(args.length() == 1); | 6298 ASSERT(args.length() == 1); |
| 6296 | 6299 |
| 6297 Object* number = args[0]; | 6300 Object* number = args[0]; |
| 6298 RUNTIME_ASSERT(number->IsNumber()); | 6301 RUNTIME_ASSERT(number->IsNumber()); |
| 6299 | 6302 |
| 6300 return isolate->heap()->NumberToString(number, false); | 6303 return isolate->heap()->NumberToString(number, false); |
| 6301 } | 6304 } |
| 6302 | 6305 |
| 6303 | 6306 |
| 6304 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6307 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { |
| 6305 NoHandleAllocation ha; | 6308 NoHandleAllocation ha(isolate); |
| 6306 ASSERT(args.length() == 1); | 6309 ASSERT(args.length() == 1); |
| 6307 | 6310 |
| 6308 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6311 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6309 | 6312 |
| 6310 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6313 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6311 if (number > 0 && number <= Smi::kMaxValue) { | 6314 if (number > 0 && number <= Smi::kMaxValue) { |
| 6312 return Smi::FromInt(static_cast<int>(number)); | 6315 return Smi::FromInt(static_cast<int>(number)); |
| 6313 } | 6316 } |
| 6314 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); | 6317 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); |
| 6315 } | 6318 } |
| 6316 | 6319 |
| 6317 | 6320 |
| 6318 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { | 6321 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { |
| 6319 NoHandleAllocation ha; | 6322 NoHandleAllocation ha(isolate); |
| 6320 ASSERT(args.length() == 1); | 6323 ASSERT(args.length() == 1); |
| 6321 | 6324 |
| 6322 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6325 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6323 | 6326 |
| 6324 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6327 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6325 if (number > 0 && number <= Smi::kMaxValue) { | 6328 if (number > 0 && number <= Smi::kMaxValue) { |
| 6326 return Smi::FromInt(static_cast<int>(number)); | 6329 return Smi::FromInt(static_cast<int>(number)); |
| 6327 } | 6330 } |
| 6328 | 6331 |
| 6329 double double_value = DoubleToInteger(number); | 6332 double double_value = DoubleToInteger(number); |
| 6330 // Map both -0 and +0 to +0. | 6333 // Map both -0 and +0 to +0. |
| 6331 if (double_value == 0) double_value = 0; | 6334 if (double_value == 0) double_value = 0; |
| 6332 | 6335 |
| 6333 return isolate->heap()->NumberFromDouble(double_value); | 6336 return isolate->heap()->NumberFromDouble(double_value); |
| 6334 } | 6337 } |
| 6335 | 6338 |
| 6336 | 6339 |
| 6337 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { | 6340 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { |
| 6338 NoHandleAllocation ha; | 6341 NoHandleAllocation ha(isolate); |
| 6339 ASSERT(args.length() == 1); | 6342 ASSERT(args.length() == 1); |
| 6340 | 6343 |
| 6341 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 6344 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
| 6342 return isolate->heap()->NumberFromUint32(number); | 6345 return isolate->heap()->NumberFromUint32(number); |
| 6343 } | 6346 } |
| 6344 | 6347 |
| 6345 | 6348 |
| 6346 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { | 6349 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { |
| 6347 NoHandleAllocation ha; | 6350 NoHandleAllocation ha(isolate); |
| 6348 ASSERT(args.length() == 1); | 6351 ASSERT(args.length() == 1); |
| 6349 | 6352 |
| 6350 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6353 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6351 | 6354 |
| 6352 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6355 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6353 if (number > 0 && number <= Smi::kMaxValue) { | 6356 if (number > 0 && number <= Smi::kMaxValue) { |
| 6354 return Smi::FromInt(static_cast<int>(number)); | 6357 return Smi::FromInt(static_cast<int>(number)); |
| 6355 } | 6358 } |
| 6356 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); | 6359 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); |
| 6357 } | 6360 } |
| 6358 | 6361 |
| 6359 | 6362 |
| 6360 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6363 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
| 6361 // a small integer. | 6364 // a small integer. |
| 6362 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { | 6365 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { |
| 6363 NoHandleAllocation ha; | 6366 NoHandleAllocation ha(isolate); |
| 6364 ASSERT(args.length() == 1); | 6367 ASSERT(args.length() == 1); |
| 6365 | 6368 |
| 6366 Object* obj = args[0]; | 6369 Object* obj = args[0]; |
| 6367 if (obj->IsSmi()) { | 6370 if (obj->IsSmi()) { |
| 6368 return obj; | 6371 return obj; |
| 6369 } | 6372 } |
| 6370 if (obj->IsHeapNumber()) { | 6373 if (obj->IsHeapNumber()) { |
| 6371 double value = HeapNumber::cast(obj)->value(); | 6374 double value = HeapNumber::cast(obj)->value(); |
| 6372 int int_value = FastD2I(value); | 6375 int int_value = FastD2I(value); |
| 6373 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6376 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
| 6374 return Smi::FromInt(int_value); | 6377 return Smi::FromInt(int_value); |
| 6375 } | 6378 } |
| 6376 } | 6379 } |
| 6377 return isolate->heap()->nan_value(); | 6380 return isolate->heap()->nan_value(); |
| 6378 } | 6381 } |
| 6379 | 6382 |
| 6380 | 6383 |
| 6381 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { | 6384 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { |
| 6382 NoHandleAllocation ha; | 6385 NoHandleAllocation ha(isolate); |
| 6383 ASSERT(args.length() == 0); | 6386 ASSERT(args.length() == 0); |
| 6384 return isolate->heap()->AllocateHeapNumber(0); | 6387 return isolate->heap()->AllocateHeapNumber(0); |
| 6385 } | 6388 } |
| 6386 | 6389 |
| 6387 | 6390 |
| 6388 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 6391 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { |
| 6389 NoHandleAllocation ha; | 6392 NoHandleAllocation ha(isolate); |
| 6390 ASSERT(args.length() == 2); | 6393 ASSERT(args.length() == 2); |
| 6391 | 6394 |
| 6392 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6395 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6393 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6396 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6394 return isolate->heap()->NumberFromDouble(x + y); | 6397 return isolate->heap()->NumberFromDouble(x + y); |
| 6395 } | 6398 } |
| 6396 | 6399 |
| 6397 | 6400 |
| 6398 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { | 6401 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { |
| 6399 NoHandleAllocation ha; | 6402 NoHandleAllocation ha(isolate); |
| 6400 ASSERT(args.length() == 2); | 6403 ASSERT(args.length() == 2); |
| 6401 | 6404 |
| 6402 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6405 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6403 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6406 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6404 return isolate->heap()->NumberFromDouble(x - y); | 6407 return isolate->heap()->NumberFromDouble(x - y); |
| 6405 } | 6408 } |
| 6406 | 6409 |
| 6407 | 6410 |
| 6408 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { | 6411 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { |
| 6409 NoHandleAllocation ha; | 6412 NoHandleAllocation ha(isolate); |
| 6410 ASSERT(args.length() == 2); | 6413 ASSERT(args.length() == 2); |
| 6411 | 6414 |
| 6412 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6415 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6413 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6416 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6414 return isolate->heap()->NumberFromDouble(x * y); | 6417 return isolate->heap()->NumberFromDouble(x * y); |
| 6415 } | 6418 } |
| 6416 | 6419 |
| 6417 | 6420 |
| 6418 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { | 6421 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { |
| 6419 NoHandleAllocation ha; | 6422 NoHandleAllocation ha(isolate); |
| 6420 ASSERT(args.length() == 1); | 6423 ASSERT(args.length() == 1); |
| 6421 | 6424 |
| 6422 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6425 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6423 return isolate->heap()->NumberFromDouble(-x); | 6426 return isolate->heap()->NumberFromDouble(-x); |
| 6424 } | 6427 } |
| 6425 | 6428 |
| 6426 | 6429 |
| 6427 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { | 6430 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { |
| 6428 NoHandleAllocation ha; | 6431 NoHandleAllocation ha(isolate); |
| 6429 ASSERT(args.length() == 0); | 6432 ASSERT(args.length() == 0); |
| 6430 | 6433 |
| 6431 return isolate->heap()->NumberFromDouble(9876543210.0); | 6434 return isolate->heap()->NumberFromDouble(9876543210.0); |
| 6432 } | 6435 } |
| 6433 | 6436 |
| 6434 | 6437 |
| 6435 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { | 6438 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { |
| 6436 NoHandleAllocation ha; | 6439 NoHandleAllocation ha(isolate); |
| 6437 ASSERT(args.length() == 2); | 6440 ASSERT(args.length() == 2); |
| 6438 | 6441 |
| 6439 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6442 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6440 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6443 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6441 return isolate->heap()->NumberFromDouble(x / y); | 6444 return isolate->heap()->NumberFromDouble(x / y); |
| 6442 } | 6445 } |
| 6443 | 6446 |
| 6444 | 6447 |
| 6445 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { | 6448 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { |
| 6446 NoHandleAllocation ha; | 6449 NoHandleAllocation ha(isolate); |
| 6447 ASSERT(args.length() == 2); | 6450 ASSERT(args.length() == 2); |
| 6448 | 6451 |
| 6449 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6452 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6450 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6453 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6451 | 6454 |
| 6452 x = modulo(x, y); | 6455 x = modulo(x, y); |
| 6453 // NumberFromDouble may return a Smi instead of a Number object | 6456 // NumberFromDouble may return a Smi instead of a Number object |
| 6454 return isolate->heap()->NumberFromDouble(x); | 6457 return isolate->heap()->NumberFromDouble(x); |
| 6455 } | 6458 } |
| 6456 | 6459 |
| 6457 | 6460 |
| 6458 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { | 6461 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { |
| 6459 NoHandleAllocation ha; | 6462 NoHandleAllocation ha(isolate); |
| 6460 ASSERT(args.length() == 2); | 6463 ASSERT(args.length() == 2); |
| 6461 CONVERT_ARG_CHECKED(String, str1, 0); | 6464 CONVERT_ARG_CHECKED(String, str1, 0); |
| 6462 CONVERT_ARG_CHECKED(String, str2, 1); | 6465 CONVERT_ARG_CHECKED(String, str2, 1); |
| 6463 isolate->counters()->string_add_runtime()->Increment(); | 6466 isolate->counters()->string_add_runtime()->Increment(); |
| 6464 return isolate->heap()->AllocateConsString(str1, str2); | 6467 return isolate->heap()->AllocateConsString(str1, str2); |
| 6465 } | 6468 } |
| 6466 | 6469 |
| 6467 | 6470 |
| 6468 template <typename sinkchar> | 6471 template <typename sinkchar> |
| 6469 static inline void StringBuilderConcatHelper(String* special, | 6472 static inline void StringBuilderConcatHelper(String* special, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 6498 String* string = String::cast(element); | 6501 String* string = String::cast(element); |
| 6499 int element_length = string->length(); | 6502 int element_length = string->length(); |
| 6500 String::WriteToFlat(string, sink + position, 0, element_length); | 6503 String::WriteToFlat(string, sink + position, 0, element_length); |
| 6501 position += element_length; | 6504 position += element_length; |
| 6502 } | 6505 } |
| 6503 } | 6506 } |
| 6504 } | 6507 } |
| 6505 | 6508 |
| 6506 | 6509 |
| 6507 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { | 6510 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { |
| 6508 NoHandleAllocation ha; | 6511 NoHandleAllocation ha(isolate); |
| 6509 ASSERT(args.length() == 3); | 6512 ASSERT(args.length() == 3); |
| 6510 CONVERT_ARG_CHECKED(JSArray, array, 0); | 6513 CONVERT_ARG_CHECKED(JSArray, array, 0); |
| 6511 if (!args[1]->IsSmi()) { | 6514 if (!args[1]->IsSmi()) { |
| 6512 isolate->context()->mark_out_of_memory(); | 6515 isolate->context()->mark_out_of_memory(); |
| 6513 return Failure::OutOfMemoryException(0x14); | 6516 return Failure::OutOfMemoryException(0x14); |
| 6514 } | 6517 } |
| 6515 int array_length = args.smi_at(1); | 6518 int array_length = args.smi_at(1); |
| 6516 CONVERT_ARG_CHECKED(String, special, 2); | 6519 CONVERT_ARG_CHECKED(String, special, 2); |
| 6517 | 6520 |
| 6518 // This assumption is used by the slice encoding in one or two smis. | 6521 // 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... | |
| 6615 StringBuilderConcatHelper(special, | 6618 StringBuilderConcatHelper(special, |
| 6616 answer->GetChars(), | 6619 answer->GetChars(), |
| 6617 fixed_array, | 6620 fixed_array, |
| 6618 array_length); | 6621 array_length); |
| 6619 return answer; | 6622 return answer; |
| 6620 } | 6623 } |
| 6621 } | 6624 } |
| 6622 | 6625 |
| 6623 | 6626 |
| 6624 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { | 6627 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { |
| 6625 NoHandleAllocation ha; | 6628 NoHandleAllocation ha(isolate); |
| 6626 ASSERT(args.length() == 3); | 6629 ASSERT(args.length() == 3); |
| 6627 CONVERT_ARG_CHECKED(JSArray, array, 0); | 6630 CONVERT_ARG_CHECKED(JSArray, array, 0); |
| 6628 if (!args[1]->IsSmi()) { | 6631 if (!args[1]->IsSmi()) { |
| 6629 isolate->context()->mark_out_of_memory(); | 6632 isolate->context()->mark_out_of_memory(); |
| 6630 return Failure::OutOfMemoryException(0x16); | 6633 return Failure::OutOfMemoryException(0x16); |
| 6631 } | 6634 } |
| 6632 int array_length = args.smi_at(1); | 6635 int array_length = args.smi_at(1); |
| 6633 CONVERT_ARG_CHECKED(String, separator, 2); | 6636 CONVERT_ARG_CHECKED(String, separator, 2); |
| 6634 | 6637 |
| 6635 if (!array->HasFastObjectElements()) { | 6638 if (!array->HasFastObjectElements()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6740 0, separator_length); | 6743 0, separator_length); |
| 6741 cursor += separator_length; | 6744 cursor += separator_length; |
| 6742 previous_separator_position++; | 6745 previous_separator_position++; |
| 6743 } | 6746 } |
| 6744 } | 6747 } |
| 6745 ASSERT(cursor <= buffer.length()); | 6748 ASSERT(cursor <= buffer.length()); |
| 6746 } | 6749 } |
| 6747 | 6750 |
| 6748 | 6751 |
| 6749 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { | 6752 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { |
| 6750 NoHandleAllocation ha; | 6753 NoHandleAllocation ha(isolate); |
| 6751 ASSERT(args.length() == 3); | 6754 ASSERT(args.length() == 3); |
| 6752 CONVERT_ARG_CHECKED(JSArray, elements_array, 0); | 6755 CONVERT_ARG_CHECKED(JSArray, elements_array, 0); |
| 6753 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); | 6756 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); |
| 6754 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 6757 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
| 6755 CONVERT_ARG_CHECKED(String, separator, 2); | 6758 CONVERT_ARG_CHECKED(String, separator, 2); |
| 6756 // elements_array is fast-mode JSarray of alternating positions | 6759 // elements_array is fast-mode JSarray of alternating positions |
| 6757 // (increasing order) and strings. | 6760 // (increasing order) and strings. |
| 6758 // array_length is length of original array (used to add separators); | 6761 // array_length is length of original array (used to add separators); |
| 6759 // separator is string to put between elements. Assumed to be non-empty. | 6762 // separator is string to put between elements. Assumed to be non-empty. |
| 6760 | 6763 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6836 array_length, | 6839 array_length, |
| 6837 separator, | 6840 separator, |
| 6838 Vector<uc16>(result_string->GetChars(), | 6841 Vector<uc16>(result_string->GetChars(), |
| 6839 string_length)); | 6842 string_length)); |
| 6840 return result_string; | 6843 return result_string; |
| 6841 } | 6844 } |
| 6842 } | 6845 } |
| 6843 | 6846 |
| 6844 | 6847 |
| 6845 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { | 6848 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { |
| 6846 NoHandleAllocation ha; | 6849 NoHandleAllocation ha(isolate); |
| 6847 ASSERT(args.length() == 2); | 6850 ASSERT(args.length() == 2); |
| 6848 | 6851 |
| 6849 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6852 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6850 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6853 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6851 return isolate->heap()->NumberFromInt32(x | y); | 6854 return isolate->heap()->NumberFromInt32(x | y); |
| 6852 } | 6855 } |
| 6853 | 6856 |
| 6854 | 6857 |
| 6855 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { | 6858 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { |
| 6856 NoHandleAllocation ha; | 6859 NoHandleAllocation ha(isolate); |
| 6857 ASSERT(args.length() == 2); | 6860 ASSERT(args.length() == 2); |
| 6858 | 6861 |
| 6859 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6862 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6860 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6863 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6861 return isolate->heap()->NumberFromInt32(x & y); | 6864 return isolate->heap()->NumberFromInt32(x & y); |
| 6862 } | 6865 } |
| 6863 | 6866 |
| 6864 | 6867 |
| 6865 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { | 6868 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { |
| 6866 NoHandleAllocation ha; | 6869 NoHandleAllocation ha(isolate); |
| 6867 ASSERT(args.length() == 2); | 6870 ASSERT(args.length() == 2); |
| 6868 | 6871 |
| 6869 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6872 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6870 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6873 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6871 return isolate->heap()->NumberFromInt32(x ^ y); | 6874 return isolate->heap()->NumberFromInt32(x ^ y); |
| 6872 } | 6875 } |
| 6873 | 6876 |
| 6874 | 6877 |
| 6875 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { | 6878 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { |
| 6876 NoHandleAllocation ha; | 6879 NoHandleAllocation ha(isolate); |
| 6877 ASSERT(args.length() == 1); | 6880 ASSERT(args.length() == 1); |
| 6878 | 6881 |
| 6879 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6882 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6880 return isolate->heap()->NumberFromInt32(~x); | 6883 return isolate->heap()->NumberFromInt32(~x); |
| 6881 } | 6884 } |
| 6882 | 6885 |
| 6883 | 6886 |
| 6884 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { | 6887 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { |
| 6885 NoHandleAllocation ha; | 6888 NoHandleAllocation ha(isolate); |
| 6886 ASSERT(args.length() == 2); | 6889 ASSERT(args.length() == 2); |
| 6887 | 6890 |
| 6888 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6891 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6889 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6892 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6890 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); | 6893 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); |
| 6891 } | 6894 } |
| 6892 | 6895 |
| 6893 | 6896 |
| 6894 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { | 6897 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { |
| 6895 NoHandleAllocation ha; | 6898 NoHandleAllocation ha(isolate); |
| 6896 ASSERT(args.length() == 2); | 6899 ASSERT(args.length() == 2); |
| 6897 | 6900 |
| 6898 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 6901 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
| 6899 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6902 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6900 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); | 6903 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); |
| 6901 } | 6904 } |
| 6902 | 6905 |
| 6903 | 6906 |
| 6904 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { | 6907 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { |
| 6905 NoHandleAllocation ha; | 6908 NoHandleAllocation ha(isolate); |
| 6906 ASSERT(args.length() == 2); | 6909 ASSERT(args.length() == 2); |
| 6907 | 6910 |
| 6908 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6911 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6909 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6912 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6910 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); | 6913 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); |
| 6911 } | 6914 } |
| 6912 | 6915 |
| 6913 | 6916 |
| 6914 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { | 6917 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { |
| 6915 NoHandleAllocation ha; | 6918 NoHandleAllocation ha(isolate); |
| 6916 ASSERT(args.length() == 2); | 6919 ASSERT(args.length() == 2); |
| 6917 | 6920 |
| 6918 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6921 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6919 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6922 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6920 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); | 6923 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); |
| 6921 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); | 6924 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); |
| 6922 if (x == y) return Smi::FromInt(EQUAL); | 6925 if (x == y) return Smi::FromInt(EQUAL); |
| 6923 Object* result; | 6926 Object* result; |
| 6924 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 6927 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
| 6925 result = Smi::FromInt(EQUAL); | 6928 result = Smi::FromInt(EQUAL); |
| 6926 } else { | 6929 } else { |
| 6927 result = Smi::FromInt(NOT_EQUAL); | 6930 result = Smi::FromInt(NOT_EQUAL); |
| 6928 } | 6931 } |
| 6929 return result; | 6932 return result; |
| 6930 } | 6933 } |
| 6931 | 6934 |
| 6932 | 6935 |
| 6933 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { | 6936 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { |
| 6934 NoHandleAllocation ha; | 6937 NoHandleAllocation ha(isolate); |
| 6935 ASSERT(args.length() == 2); | 6938 ASSERT(args.length() == 2); |
| 6936 | 6939 |
| 6937 CONVERT_ARG_CHECKED(String, x, 0); | 6940 CONVERT_ARG_CHECKED(String, x, 0); |
| 6938 CONVERT_ARG_CHECKED(String, y, 1); | 6941 CONVERT_ARG_CHECKED(String, y, 1); |
| 6939 | 6942 |
| 6940 bool not_equal = !x->Equals(y); | 6943 bool not_equal = !x->Equals(y); |
| 6941 // This is slightly convoluted because the value that signifies | 6944 // This is slightly convoluted because the value that signifies |
| 6942 // equality is 0 and inequality is 1 so we have to negate the result | 6945 // equality is 0 and inequality is 1 so we have to negate the result |
| 6943 // from String::Equals. | 6946 // from String::Equals. |
| 6944 ASSERT(not_equal == 0 || not_equal == 1); | 6947 ASSERT(not_equal == 0 || not_equal == 1); |
| 6945 STATIC_CHECK(EQUAL == 0); | 6948 STATIC_CHECK(EQUAL == 0); |
| 6946 STATIC_CHECK(NOT_EQUAL == 1); | 6949 STATIC_CHECK(NOT_EQUAL == 1); |
| 6947 return Smi::FromInt(not_equal); | 6950 return Smi::FromInt(not_equal); |
| 6948 } | 6951 } |
| 6949 | 6952 |
| 6950 | 6953 |
| 6951 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { | 6954 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { |
| 6952 NoHandleAllocation ha; | 6955 NoHandleAllocation ha(isolate); |
| 6953 ASSERT(args.length() == 3); | 6956 ASSERT(args.length() == 3); |
| 6954 | 6957 |
| 6955 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6958 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6956 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6959 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6957 if (isnan(x) || isnan(y)) return args[2]; | 6960 if (isnan(x) || isnan(y)) return args[2]; |
| 6958 if (x == y) return Smi::FromInt(EQUAL); | 6961 if (x == y) return Smi::FromInt(EQUAL); |
| 6959 if (isless(x, y)) return Smi::FromInt(LESS); | 6962 if (isless(x, y)) return Smi::FromInt(LESS); |
| 6960 return Smi::FromInt(GREATER); | 6963 return Smi::FromInt(GREATER); |
| 6961 } | 6964 } |
| 6962 | 6965 |
| 6963 | 6966 |
| 6964 // Compare two Smis as if they were converted to strings and then | 6967 // Compare two Smis as if they were converted to strings and then |
| 6965 // compared lexicographically. | 6968 // compared lexicographically. |
| 6966 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { | 6969 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { |
| 6967 NoHandleAllocation ha; | 6970 NoHandleAllocation ha(isolate); |
| 6968 ASSERT(args.length() == 2); | 6971 ASSERT(args.length() == 2); |
| 6969 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 6972 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
| 6970 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 6973 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
| 6971 | 6974 |
| 6972 // If the integers are equal so are the string representations. | 6975 // If the integers are equal so are the string representations. |
| 6973 if (x_value == y_value) return Smi::FromInt(EQUAL); | 6976 if (x_value == y_value) return Smi::FromInt(EQUAL); |
| 6974 | 6977 |
| 6975 // If one of the integers is zero the normal integer order is the | 6978 // If one of the integers is zero the normal integer order is the |
| 6976 // same as the lexicographic order of the string representations. | 6979 // same as the lexicographic order of the string representations. |
| 6977 if (x_value == 0 || y_value == 0) | 6980 if (x_value == 0 || y_value == 0) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7095 } else { | 7098 } else { |
| 7096 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7099 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
| 7097 } | 7100 } |
| 7098 ASSERT(result == | 7101 ASSERT(result == |
| 7099 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); | 7102 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); |
| 7100 return result; | 7103 return result; |
| 7101 } | 7104 } |
| 7102 | 7105 |
| 7103 | 7106 |
| 7104 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { | 7107 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { |
| 7105 NoHandleAllocation ha; | 7108 NoHandleAllocation ha(isolate); |
| 7106 ASSERT(args.length() == 2); | 7109 ASSERT(args.length() == 2); |
| 7107 | 7110 |
| 7108 CONVERT_ARG_CHECKED(String, x, 0); | 7111 CONVERT_ARG_CHECKED(String, x, 0); |
| 7109 CONVERT_ARG_CHECKED(String, y, 1); | 7112 CONVERT_ARG_CHECKED(String, y, 1); |
| 7110 | 7113 |
| 7111 isolate->counters()->string_compare_runtime()->Increment(); | 7114 isolate->counters()->string_compare_runtime()->Increment(); |
| 7112 | 7115 |
| 7113 // A few fast case tests before we flatten. | 7116 // A few fast case tests before we flatten. |
| 7114 if (x == y) return Smi::FromInt(EQUAL); | 7117 if (x == y) return Smi::FromInt(EQUAL); |
| 7115 if (y->length() == 0) { | 7118 if (y->length() == 0) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 7130 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); | 7133 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); |
| 7131 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7134 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 7132 } | 7135 } |
| 7133 | 7136 |
| 7134 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) | 7137 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) |
| 7135 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); | 7138 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); |
| 7136 } | 7139 } |
| 7137 | 7140 |
| 7138 | 7141 |
| 7139 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { | 7142 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { |
| 7140 NoHandleAllocation ha; | 7143 NoHandleAllocation ha(isolate); |
| 7141 ASSERT(args.length() == 1); | 7144 ASSERT(args.length() == 1); |
| 7142 isolate->counters()->math_acos()->Increment(); | 7145 isolate->counters()->math_acos()->Increment(); |
| 7143 | 7146 |
| 7144 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7147 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7145 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); | 7148 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); |
| 7146 } | 7149 } |
| 7147 | 7150 |
| 7148 | 7151 |
| 7149 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { | 7152 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { |
| 7150 NoHandleAllocation ha; | 7153 NoHandleAllocation ha(isolate); |
| 7151 ASSERT(args.length() == 1); | 7154 ASSERT(args.length() == 1); |
| 7152 isolate->counters()->math_asin()->Increment(); | 7155 isolate->counters()->math_asin()->Increment(); |
| 7153 | 7156 |
| 7154 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7157 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7155 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); | 7158 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); |
| 7156 } | 7159 } |
| 7157 | 7160 |
| 7158 | 7161 |
| 7159 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { | 7162 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { |
| 7160 NoHandleAllocation ha; | 7163 NoHandleAllocation ha(isolate); |
| 7161 ASSERT(args.length() == 1); | 7164 ASSERT(args.length() == 1); |
| 7162 isolate->counters()->math_atan()->Increment(); | 7165 isolate->counters()->math_atan()->Increment(); |
| 7163 | 7166 |
| 7164 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7167 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7165 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); | 7168 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); |
| 7166 } | 7169 } |
| 7167 | 7170 |
| 7168 | 7171 |
| 7169 static const double kPiDividedBy4 = 0.78539816339744830962; | 7172 static const double kPiDividedBy4 = 0.78539816339744830962; |
| 7170 | 7173 |
| 7171 | 7174 |
| 7172 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { | 7175 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { |
| 7173 NoHandleAllocation ha; | 7176 NoHandleAllocation ha(isolate); |
| 7174 ASSERT(args.length() == 2); | 7177 ASSERT(args.length() == 2); |
| 7175 isolate->counters()->math_atan2()->Increment(); | 7178 isolate->counters()->math_atan2()->Increment(); |
| 7176 | 7179 |
| 7177 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7180 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7178 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7181 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7179 double result; | 7182 double result; |
| 7180 if (isinf(x) && isinf(y)) { | 7183 if (isinf(x) && isinf(y)) { |
| 7181 // Make sure that the result in case of two infinite arguments | 7184 // Make sure that the result in case of two infinite arguments |
| 7182 // is a multiple of Pi / 4. The sign of the result is determined | 7185 // is a multiple of Pi / 4. The sign of the result is determined |
| 7183 // by the first argument (x) and the sign of the second argument | 7186 // by the first argument (x) and the sign of the second argument |
| 7184 // determines the multiplier: one or three. | 7187 // determines the multiplier: one or three. |
| 7185 int multiplier = (x < 0) ? -1 : 1; | 7188 int multiplier = (x < 0) ? -1 : 1; |
| 7186 if (y < 0) multiplier *= 3; | 7189 if (y < 0) multiplier *= 3; |
| 7187 result = multiplier * kPiDividedBy4; | 7190 result = multiplier * kPiDividedBy4; |
| 7188 } else { | 7191 } else { |
| 7189 result = atan2(x, y); | 7192 result = atan2(x, y); |
| 7190 } | 7193 } |
| 7191 return isolate->heap()->AllocateHeapNumber(result); | 7194 return isolate->heap()->AllocateHeapNumber(result); |
| 7192 } | 7195 } |
| 7193 | 7196 |
| 7194 | 7197 |
| 7195 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { | 7198 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { |
| 7196 NoHandleAllocation ha; | 7199 NoHandleAllocation ha(isolate); |
| 7197 ASSERT(args.length() == 1); | 7200 ASSERT(args.length() == 1); |
| 7198 isolate->counters()->math_ceil()->Increment(); | 7201 isolate->counters()->math_ceil()->Increment(); |
| 7199 | 7202 |
| 7200 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7203 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7201 return isolate->heap()->NumberFromDouble(ceiling(x)); | 7204 return isolate->heap()->NumberFromDouble(ceiling(x)); |
| 7202 } | 7205 } |
| 7203 | 7206 |
| 7204 | 7207 |
| 7205 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { | 7208 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { |
| 7206 NoHandleAllocation ha; | 7209 NoHandleAllocation ha(isolate); |
| 7207 ASSERT(args.length() == 1); | 7210 ASSERT(args.length() == 1); |
| 7208 isolate->counters()->math_cos()->Increment(); | 7211 isolate->counters()->math_cos()->Increment(); |
| 7209 | 7212 |
| 7210 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7213 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7211 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); | 7214 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); |
| 7212 } | 7215 } |
| 7213 | 7216 |
| 7214 | 7217 |
| 7215 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { | 7218 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { |
| 7216 NoHandleAllocation ha; | 7219 NoHandleAllocation ha(isolate); |
| 7217 ASSERT(args.length() == 1); | 7220 ASSERT(args.length() == 1); |
| 7218 isolate->counters()->math_exp()->Increment(); | 7221 isolate->counters()->math_exp()->Increment(); |
| 7219 | 7222 |
| 7220 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7223 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7221 lazily_initialize_fast_exp(); | 7224 lazily_initialize_fast_exp(); |
| 7222 return isolate->heap()->NumberFromDouble(fast_exp(x)); | 7225 return isolate->heap()->NumberFromDouble(fast_exp(x)); |
| 7223 } | 7226 } |
| 7224 | 7227 |
| 7225 | 7228 |
| 7226 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { | 7229 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { |
| 7227 NoHandleAllocation ha; | 7230 NoHandleAllocation ha(isolate); |
| 7228 ASSERT(args.length() == 1); | 7231 ASSERT(args.length() == 1); |
| 7229 isolate->counters()->math_floor()->Increment(); | 7232 isolate->counters()->math_floor()->Increment(); |
| 7230 | 7233 |
| 7231 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7234 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7232 return isolate->heap()->NumberFromDouble(floor(x)); | 7235 return isolate->heap()->NumberFromDouble(floor(x)); |
| 7233 } | 7236 } |
| 7234 | 7237 |
| 7235 | 7238 |
| 7236 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { | 7239 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { |
| 7237 NoHandleAllocation ha; | 7240 NoHandleAllocation ha(isolate); |
| 7238 ASSERT(args.length() == 1); | 7241 ASSERT(args.length() == 1); |
| 7239 isolate->counters()->math_log()->Increment(); | 7242 isolate->counters()->math_log()->Increment(); |
| 7240 | 7243 |
| 7241 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7244 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7242 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); | 7245 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); |
| 7243 } | 7246 } |
| 7244 | 7247 |
| 7245 // Slow version of Math.pow. We check for fast paths for special cases. | 7248 // Slow version of Math.pow. We check for fast paths for special cases. |
| 7246 // Used if SSE2/VFP3 is not available. | 7249 // Used if SSE2/VFP3 is not available. |
| 7247 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { | 7250 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { |
| 7248 NoHandleAllocation ha; | 7251 NoHandleAllocation ha(isolate); |
| 7249 ASSERT(args.length() == 2); | 7252 ASSERT(args.length() == 2); |
| 7250 isolate->counters()->math_pow()->Increment(); | 7253 isolate->counters()->math_pow()->Increment(); |
| 7251 | 7254 |
| 7252 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7255 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7253 | 7256 |
| 7254 // If the second argument is a smi, it is much faster to call the | 7257 // If the second argument is a smi, it is much faster to call the |
| 7255 // custom powi() function than the generic pow(). | 7258 // custom powi() function than the generic pow(). |
| 7256 if (args[1]->IsSmi()) { | 7259 if (args[1]->IsSmi()) { |
| 7257 int y = args.smi_at(1); | 7260 int y = args.smi_at(1); |
| 7258 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); | 7261 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 7272 } else { | 7275 } else { |
| 7273 result = power_double_double(x, y); | 7276 result = power_double_double(x, y); |
| 7274 } | 7277 } |
| 7275 if (isnan(result)) return isolate->heap()->nan_value(); | 7278 if (isnan(result)) return isolate->heap()->nan_value(); |
| 7276 return isolate->heap()->AllocateHeapNumber(result); | 7279 return isolate->heap()->AllocateHeapNumber(result); |
| 7277 } | 7280 } |
| 7278 | 7281 |
| 7279 // Fast version of Math.pow if we know that y is not an integer and y is not | 7282 // Fast version of Math.pow if we know that y is not an integer and y is not |
| 7280 // -0.5 or 0.5. Used as slow case from full codegen. | 7283 // -0.5 or 0.5. Used as slow case from full codegen. |
| 7281 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { | 7284 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { |
| 7282 NoHandleAllocation ha; | 7285 NoHandleAllocation ha(isolate); |
| 7283 ASSERT(args.length() == 2); | 7286 ASSERT(args.length() == 2); |
| 7284 isolate->counters()->math_pow()->Increment(); | 7287 isolate->counters()->math_pow()->Increment(); |
| 7285 | 7288 |
| 7286 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7289 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7287 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7290 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7288 if (y == 0) { | 7291 if (y == 0) { |
| 7289 return Smi::FromInt(1); | 7292 return Smi::FromInt(1); |
| 7290 } else { | 7293 } else { |
| 7291 double result = power_double_double(x, y); | 7294 double result = power_double_double(x, y); |
| 7292 if (isnan(result)) return isolate->heap()->nan_value(); | 7295 if (isnan(result)) return isolate->heap()->nan_value(); |
| 7293 return isolate->heap()->AllocateHeapNumber(result); | 7296 return isolate->heap()->AllocateHeapNumber(result); |
| 7294 } | 7297 } |
| 7295 } | 7298 } |
| 7296 | 7299 |
| 7297 | 7300 |
| 7298 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { | 7301 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { |
| 7299 NoHandleAllocation ha; | 7302 NoHandleAllocation ha(isolate); |
| 7300 ASSERT(args.length() == 1); | 7303 ASSERT(args.length() == 1); |
| 7301 isolate->counters()->math_round()->Increment(); | 7304 isolate->counters()->math_round()->Increment(); |
| 7302 | 7305 |
| 7303 if (!args[0]->IsHeapNumber()) { | 7306 if (!args[0]->IsHeapNumber()) { |
| 7304 // Must be smi. Return the argument unchanged for all the other types | 7307 // Must be smi. Return the argument unchanged for all the other types |
| 7305 // to make fuzz-natives test happy. | 7308 // to make fuzz-natives test happy. |
| 7306 return args[0]; | 7309 return args[0]; |
| 7307 } | 7310 } |
| 7308 | 7311 |
| 7309 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); | 7312 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 7332 } | 7335 } |
| 7333 | 7336 |
| 7334 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7337 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
| 7335 | 7338 |
| 7336 // Do not call NumberFromDouble() to avoid extra checks. | 7339 // Do not call NumberFromDouble() to avoid extra checks. |
| 7337 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); | 7340 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); |
| 7338 } | 7341 } |
| 7339 | 7342 |
| 7340 | 7343 |
| 7341 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { | 7344 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { |
| 7342 NoHandleAllocation ha; | 7345 NoHandleAllocation ha(isolate); |
| 7343 ASSERT(args.length() == 1); | 7346 ASSERT(args.length() == 1); |
| 7344 isolate->counters()->math_sin()->Increment(); | 7347 isolate->counters()->math_sin()->Increment(); |
| 7345 | 7348 |
| 7346 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7349 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7347 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); | 7350 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); |
| 7348 } | 7351 } |
| 7349 | 7352 |
| 7350 | 7353 |
| 7351 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { | 7354 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { |
| 7352 NoHandleAllocation ha; | 7355 NoHandleAllocation ha(isolate); |
| 7353 ASSERT(args.length() == 1); | 7356 ASSERT(args.length() == 1); |
| 7354 isolate->counters()->math_sqrt()->Increment(); | 7357 isolate->counters()->math_sqrt()->Increment(); |
| 7355 | 7358 |
| 7356 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7359 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7357 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); | 7360 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); |
| 7358 } | 7361 } |
| 7359 | 7362 |
| 7360 | 7363 |
| 7361 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { | 7364 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { |
| 7362 NoHandleAllocation ha; | 7365 NoHandleAllocation ha(isolate); |
| 7363 ASSERT(args.length() == 1); | 7366 ASSERT(args.length() == 1); |
| 7364 isolate->counters()->math_tan()->Increment(); | 7367 isolate->counters()->math_tan()->Increment(); |
| 7365 | 7368 |
| 7366 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7369 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7367 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); | 7370 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); |
| 7368 } | 7371 } |
| 7369 | 7372 |
| 7370 | 7373 |
| 7371 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7374 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
| 7372 NoHandleAllocation ha; | 7375 NoHandleAllocation ha(isolate); |
| 7373 ASSERT(args.length() == 2); | 7376 ASSERT(args.length() == 2); |
| 7374 | 7377 |
| 7375 CONVERT_SMI_ARG_CHECKED(year, 0); | 7378 CONVERT_SMI_ARG_CHECKED(year, 0); |
| 7376 CONVERT_SMI_ARG_CHECKED(month, 1); | 7379 CONVERT_SMI_ARG_CHECKED(month, 1); |
| 7377 | 7380 |
| 7378 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7381 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
| 7379 } | 7382 } |
| 7380 | 7383 |
| 7381 | 7384 |
| 7382 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { | 7385 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7505 for (int i = 0; i < argument_count; ++i) { | 7508 for (int i = 0; i < argument_count; ++i) { |
| 7506 elements->set(i, *(parameters - i - 1)); | 7509 elements->set(i, *(parameters - i - 1)); |
| 7507 } | 7510 } |
| 7508 } | 7511 } |
| 7509 } | 7512 } |
| 7510 return *result; | 7513 return *result; |
| 7511 } | 7514 } |
| 7512 | 7515 |
| 7513 | 7516 |
| 7514 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) { | 7517 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) { |
| 7515 NoHandleAllocation ha; | 7518 NoHandleAllocation ha(isolate); |
| 7516 ASSERT(args.length() == 3); | 7519 ASSERT(args.length() == 3); |
| 7517 | 7520 |
| 7518 JSFunction* callee = JSFunction::cast(args[0]); | 7521 JSFunction* callee = JSFunction::cast(args[0]); |
| 7519 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7522 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 7520 const int length = args.smi_at(2); | 7523 const int length = args.smi_at(2); |
| 7521 | 7524 |
| 7522 Object* result; | 7525 Object* result; |
| 7523 { MaybeObject* maybe_result = | 7526 { MaybeObject* maybe_result = |
| 7524 isolate->heap()->AllocateArgumentsObject(callee, length); | 7527 isolate->heap()->AllocateArgumentsObject(callee, length); |
| 7525 if (!maybe_result->ToObject(&result)) return maybe_result; | 7528 if (!maybe_result->ToObject(&result)) return maybe_result; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7585 frame, | 7588 frame, |
| 7586 inlined_jsframe_index, | 7589 inlined_jsframe_index, |
| 7587 inlined_function->shared()->formal_parameter_count()); | 7590 inlined_function->shared()->formal_parameter_count()); |
| 7588 | 7591 |
| 7589 int args_count = args_slots.length(); | 7592 int args_count = args_slots.length(); |
| 7590 | 7593 |
| 7591 *total_argc = prefix_argc + args_count; | 7594 *total_argc = prefix_argc + args_count; |
| 7592 SmartArrayPointer<Handle<Object> > param_data( | 7595 SmartArrayPointer<Handle<Object> > param_data( |
| 7593 NewArray<Handle<Object> >(*total_argc)); | 7596 NewArray<Handle<Object> >(*total_argc)); |
| 7594 for (int i = 0; i < args_count; i++) { | 7597 for (int i = 0; i < args_count; i++) { |
| 7595 Handle<Object> val = args_slots[i].GetValue(); | 7598 Handle<Object> val = args_slots[i].GetValue(isolate); |
| 7596 param_data[prefix_argc + i] = val; | 7599 param_data[prefix_argc + i] = val; |
| 7597 } | 7600 } |
| 7598 | 7601 |
| 7599 args_slots.Dispose(); | 7602 args_slots.Dispose(); |
| 7600 | 7603 |
| 7601 return param_data; | 7604 return param_data; |
| 7602 } else { | 7605 } else { |
| 7603 it.AdvanceToArgumentsFrame(); | 7606 it.AdvanceToArgumentsFrame(); |
| 7604 frame = it.frame(); | 7607 frame = it.frame(); |
| 7605 int args_count = frame->ComputeParametersCount(); | 7608 int args_count = frame->ComputeParametersCount(); |
| 7606 | 7609 |
| 7607 *total_argc = prefix_argc + args_count; | 7610 *total_argc = prefix_argc + args_count; |
| 7608 SmartArrayPointer<Handle<Object> > param_data( | 7611 SmartArrayPointer<Handle<Object> > param_data( |
| 7609 NewArray<Handle<Object> >(*total_argc)); | 7612 NewArray<Handle<Object> >(*total_argc)); |
| 7610 for (int i = 0; i < args_count; i++) { | 7613 for (int i = 0; i < args_count; i++) { |
| 7611 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); | 7614 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); |
| 7612 param_data[prefix_argc + i] = val; | 7615 param_data[prefix_argc + i] = val; |
| 7613 } | 7616 } |
| 7614 return param_data; | 7617 return param_data; |
| 7615 } | 7618 } |
| 7616 } | 7619 } |
| 7617 | 7620 |
| 7618 | 7621 |
| 7619 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { | 7622 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { |
| 7620 HandleScope scope(isolate); | 7623 HandleScope scope(isolate); |
| 7621 ASSERT(args.length() == 4); | 7624 ASSERT(args.length() == 4); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 7638 } | 7641 } |
| 7639 // Initialize array of bindings (function, this, and any existing arguments | 7642 // Initialize array of bindings (function, this, and any existing arguments |
| 7640 // if the function was already bound). | 7643 // if the function was already bound). |
| 7641 Handle<FixedArray> new_bindings; | 7644 Handle<FixedArray> new_bindings; |
| 7642 int i; | 7645 int i; |
| 7643 if (bindee->IsJSFunction() && JSFunction::cast(*bindee)->shared()->bound()) { | 7646 if (bindee->IsJSFunction() && JSFunction::cast(*bindee)->shared()->bound()) { |
| 7644 Handle<FixedArray> old_bindings( | 7647 Handle<FixedArray> old_bindings( |
| 7645 JSFunction::cast(*bindee)->function_bindings()); | 7648 JSFunction::cast(*bindee)->function_bindings()); |
| 7646 new_bindings = | 7649 new_bindings = |
| 7647 isolate->factory()->NewFixedArray(old_bindings->length() + argc); | 7650 isolate->factory()->NewFixedArray(old_bindings->length() + argc); |
| 7648 bindee = Handle<Object>(old_bindings->get(JSFunction::kBoundFunctionIndex)); | 7651 bindee = Handle<Object>(old_bindings->get(JSFunction::kBoundFunctionIndex), |
| 7652 isolate); | |
| 7649 i = 0; | 7653 i = 0; |
| 7650 for (int n = old_bindings->length(); i < n; i++) { | 7654 for (int n = old_bindings->length(); i < n; i++) { |
| 7651 new_bindings->set(i, old_bindings->get(i)); | 7655 new_bindings->set(i, old_bindings->get(i)); |
| 7652 } | 7656 } |
| 7653 } else { | 7657 } else { |
| 7654 int array_size = JSFunction::kBoundArgumentsStartIndex + argc; | 7658 int array_size = JSFunction::kBoundArgumentsStartIndex + argc; |
| 7655 new_bindings = isolate->factory()->NewFixedArray(array_size); | 7659 new_bindings = isolate->factory()->NewFixedArray(array_size); |
| 7656 new_bindings->set(JSFunction::kBoundFunctionIndex, *bindee); | 7660 new_bindings->set(JSFunction::kBoundFunctionIndex, *bindee); |
| 7657 new_bindings->set(JSFunction::kBoundThisIndex, args[2]); | 7661 new_bindings->set(JSFunction::kBoundThisIndex, args[2]); |
| 7658 i = 2; | 7662 i = 2; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7697 // First argument is a function to use as a constructor. | 7701 // First argument is a function to use as a constructor. |
| 7698 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 7702 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 7699 RUNTIME_ASSERT(function->shared()->bound()); | 7703 RUNTIME_ASSERT(function->shared()->bound()); |
| 7700 | 7704 |
| 7701 // The argument is a bound function. Extract its bound arguments | 7705 // The argument is a bound function. Extract its bound arguments |
| 7702 // and callable. | 7706 // and callable. |
| 7703 Handle<FixedArray> bound_args = | 7707 Handle<FixedArray> bound_args = |
| 7704 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); | 7708 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); |
| 7705 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; | 7709 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; |
| 7706 Handle<Object> bound_function( | 7710 Handle<Object> bound_function( |
| 7707 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex))); | 7711 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)), |
| 7712 isolate); | |
| 7708 ASSERT(!bound_function->IsJSFunction() || | 7713 ASSERT(!bound_function->IsJSFunction() || |
| 7709 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); | 7714 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); |
| 7710 | 7715 |
| 7711 int total_argc = 0; | 7716 int total_argc = 0; |
| 7712 SmartArrayPointer<Handle<Object> > param_data = | 7717 SmartArrayPointer<Handle<Object> > param_data = |
| 7713 GetCallerArguments(isolate, bound_argc, &total_argc); | 7718 GetCallerArguments(isolate, bound_argc, &total_argc); |
| 7714 for (int i = 0; i < bound_argc; i++) { | 7719 for (int i = 0; i < bound_argc; i++) { |
| 7715 param_data[i] = Handle<Object>(bound_args->get( | 7720 param_data[i] = Handle<Object>(bound_args->get( |
| 7716 JSFunction::kBoundArgumentsStartIndex + i)); | 7721 JSFunction::kBoundArgumentsStartIndex + i), isolate); |
| 7717 } | 7722 } |
| 7718 | 7723 |
| 7719 if (!bound_function->IsJSFunction()) { | 7724 if (!bound_function->IsJSFunction()) { |
| 7720 bool exception_thrown; | 7725 bool exception_thrown; |
| 7721 bound_function = Execution::TryGetConstructorDelegate(bound_function, | 7726 bound_function = Execution::TryGetConstructorDelegate(bound_function, |
| 7722 &exception_thrown); | 7727 &exception_thrown); |
| 7723 if (exception_thrown) return Failure::Exception(); | 7728 if (exception_thrown) return Failure::Exception(); |
| 7724 } | 7729 } |
| 7725 ASSERT(bound_function->IsJSFunction()); | 7730 ASSERT(bound_function->IsJSFunction()); |
| 7726 | 7731 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8280 if (argc > argv_small_size) { | 8285 if (argc > argv_small_size) { |
| 8281 argv = new Handle<Object>[argc]; | 8286 argv = new Handle<Object>[argc]; |
| 8282 if (argv == NULL) return isolate->StackOverflow(); | 8287 if (argv == NULL) return isolate->StackOverflow(); |
| 8283 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); | 8288 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); |
| 8284 } | 8289 } |
| 8285 | 8290 |
| 8286 for (int i = 0; i < argc; ++i) { | 8291 for (int i = 0; i < argc; ++i) { |
| 8287 MaybeObject* maybe = args[1 + i]; | 8292 MaybeObject* maybe = args[1 + i]; |
| 8288 Object* object; | 8293 Object* object; |
| 8289 if (!maybe->To<Object>(&object)) return maybe; | 8294 if (!maybe->To<Object>(&object)) return maybe; |
| 8290 argv[i] = Handle<Object>(object); | 8295 argv[i] = Handle<Object>(object, isolate); |
| 8291 } | 8296 } |
| 8292 | 8297 |
| 8293 bool threw; | 8298 bool threw; |
| 8294 Handle<JSReceiver> hfun(fun); | 8299 Handle<JSReceiver> hfun(fun); |
| 8295 Handle<Object> hreceiver(receiver); | 8300 Handle<Object> hreceiver(receiver, isolate); |
| 8296 Handle<Object> result = | 8301 Handle<Object> result = |
| 8297 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); | 8302 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); |
| 8298 | 8303 |
| 8299 if (threw) return Failure::Exception(); | 8304 if (threw) return Failure::Exception(); |
| 8300 return *result; | 8305 return *result; |
| 8301 } | 8306 } |
| 8302 | 8307 |
| 8303 | 8308 |
| 8304 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { | 8309 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { |
| 8305 HandleScope scope(isolate); | 8310 HandleScope scope(isolate); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8346 | 8351 |
| 8347 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 8352 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { |
| 8348 HandleScope scope(isolate); | 8353 HandleScope scope(isolate); |
| 8349 ASSERT(args.length() == 1); | 8354 ASSERT(args.length() == 1); |
| 8350 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 8355 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
| 8351 return *Execution::GetConstructorDelegate(args.at<Object>(0)); | 8356 return *Execution::GetConstructorDelegate(args.at<Object>(0)); |
| 8352 } | 8357 } |
| 8353 | 8358 |
| 8354 | 8359 |
| 8355 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { | 8360 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { |
| 8356 NoHandleAllocation ha; | 8361 NoHandleAllocation ha(isolate); |
| 8357 ASSERT(args.length() == 2); | 8362 ASSERT(args.length() == 2); |
| 8358 | 8363 |
| 8359 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8364 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8360 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); | 8365 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); |
| 8361 Context* result; | 8366 Context* result; |
| 8362 MaybeObject* maybe_result = | 8367 MaybeObject* maybe_result = |
| 8363 isolate->heap()->AllocateGlobalContext(function, scope_info); | 8368 isolate->heap()->AllocateGlobalContext(function, scope_info); |
| 8364 if (!maybe_result->To(&result)) return maybe_result; | 8369 if (!maybe_result->To(&result)) return maybe_result; |
| 8365 | 8370 |
| 8366 ASSERT(function->context() == isolate->context()); | 8371 ASSERT(function->context() == isolate->context()); |
| 8367 ASSERT(function->context()->global_object() == result->global_object()); | 8372 ASSERT(function->context()->global_object() == result->global_object()); |
| 8368 isolate->set_context(result); | 8373 isolate->set_context(result); |
| 8369 result->global_object()->set_global_context(result); | 8374 result->global_object()->set_global_context(result); |
| 8370 | 8375 |
| 8371 return result; // non-failure | 8376 return result; // non-failure |
| 8372 } | 8377 } |
| 8373 | 8378 |
| 8374 | 8379 |
| 8375 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { | 8380 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { |
| 8376 NoHandleAllocation ha; | 8381 NoHandleAllocation ha(isolate); |
| 8377 ASSERT(args.length() == 1); | 8382 ASSERT(args.length() == 1); |
| 8378 | 8383 |
| 8379 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8384 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8380 int length = function->shared()->scope_info()->ContextLength(); | 8385 int length = function->shared()->scope_info()->ContextLength(); |
| 8381 Context* result; | 8386 Context* result; |
| 8382 MaybeObject* maybe_result = | 8387 MaybeObject* maybe_result = |
| 8383 isolate->heap()->AllocateFunctionContext(length, function); | 8388 isolate->heap()->AllocateFunctionContext(length, function); |
| 8384 if (!maybe_result->To(&result)) return maybe_result; | 8389 if (!maybe_result->To(&result)) return maybe_result; |
| 8385 | 8390 |
| 8386 isolate->set_context(result); | 8391 isolate->set_context(result); |
| 8387 | 8392 |
| 8388 return result; // non-failure | 8393 return result; // non-failure |
| 8389 } | 8394 } |
| 8390 | 8395 |
| 8391 | 8396 |
| 8392 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { | 8397 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { |
| 8393 NoHandleAllocation ha; | 8398 NoHandleAllocation ha(isolate); |
| 8394 ASSERT(args.length() == 2); | 8399 ASSERT(args.length() == 2); |
| 8395 JSObject* extension_object; | 8400 JSObject* extension_object; |
| 8396 if (args[0]->IsJSObject()) { | 8401 if (args[0]->IsJSObject()) { |
| 8397 extension_object = JSObject::cast(args[0]); | 8402 extension_object = JSObject::cast(args[0]); |
| 8398 } else { | 8403 } else { |
| 8399 // Convert the object to a proper JavaScript object. | 8404 // Convert the object to a proper JavaScript object. |
| 8400 MaybeObject* maybe_js_object = args[0]->ToObject(); | 8405 MaybeObject* maybe_js_object = args[0]->ToObject(); |
| 8401 if (!maybe_js_object->To(&extension_object)) { | 8406 if (!maybe_js_object->To(&extension_object)) { |
| 8402 if (Failure::cast(maybe_js_object)->IsInternalError()) { | 8407 if (Failure::cast(maybe_js_object)->IsInternalError()) { |
| 8403 HandleScope scope(isolate); | 8408 HandleScope scope(isolate); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 8427 isolate->heap()->AllocateWithContext(function, | 8432 isolate->heap()->AllocateWithContext(function, |
| 8428 isolate->context(), | 8433 isolate->context(), |
| 8429 extension_object); | 8434 extension_object); |
| 8430 if (!maybe_context->To(&context)) return maybe_context; | 8435 if (!maybe_context->To(&context)) return maybe_context; |
| 8431 isolate->set_context(context); | 8436 isolate->set_context(context); |
| 8432 return context; | 8437 return context; |
| 8433 } | 8438 } |
| 8434 | 8439 |
| 8435 | 8440 |
| 8436 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { | 8441 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { |
| 8437 NoHandleAllocation ha; | 8442 NoHandleAllocation ha(isolate); |
| 8438 ASSERT(args.length() == 3); | 8443 ASSERT(args.length() == 3); |
| 8439 String* name = String::cast(args[0]); | 8444 String* name = String::cast(args[0]); |
| 8440 Object* thrown_object = args[1]; | 8445 Object* thrown_object = args[1]; |
| 8441 JSFunction* function; | 8446 JSFunction* function; |
| 8442 if (args[2]->IsSmi()) { | 8447 if (args[2]->IsSmi()) { |
| 8443 // A smi sentinel indicates a context nested inside global code rather | 8448 // A smi sentinel indicates a context nested inside global code rather |
| 8444 // than some function. There is a canonical empty function that can be | 8449 // than some function. There is a canonical empty function that can be |
| 8445 // gotten from the native context. | 8450 // gotten from the native context. |
| 8446 function = isolate->context()->native_context()->closure(); | 8451 function = isolate->context()->native_context()->closure(); |
| 8447 } else { | 8452 } else { |
| 8448 function = JSFunction::cast(args[2]); | 8453 function = JSFunction::cast(args[2]); |
| 8449 } | 8454 } |
| 8450 Context* context; | 8455 Context* context; |
| 8451 MaybeObject* maybe_context = | 8456 MaybeObject* maybe_context = |
| 8452 isolate->heap()->AllocateCatchContext(function, | 8457 isolate->heap()->AllocateCatchContext(function, |
| 8453 isolate->context(), | 8458 isolate->context(), |
| 8454 name, | 8459 name, |
| 8455 thrown_object); | 8460 thrown_object); |
| 8456 if (!maybe_context->To(&context)) return maybe_context; | 8461 if (!maybe_context->To(&context)) return maybe_context; |
| 8457 isolate->set_context(context); | 8462 isolate->set_context(context); |
| 8458 return context; | 8463 return context; |
| 8459 } | 8464 } |
| 8460 | 8465 |
| 8461 | 8466 |
| 8462 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { | 8467 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { |
| 8463 NoHandleAllocation ha; | 8468 NoHandleAllocation ha(isolate); |
| 8464 ASSERT(args.length() == 2); | 8469 ASSERT(args.length() == 2); |
| 8465 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); | 8470 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); |
| 8466 JSFunction* function; | 8471 JSFunction* function; |
| 8467 if (args[1]->IsSmi()) { | 8472 if (args[1]->IsSmi()) { |
| 8468 // A smi sentinel indicates a context nested inside global code rather | 8473 // A smi sentinel indicates a context nested inside global code rather |
| 8469 // than some function. There is a canonical empty function that can be | 8474 // than some function. There is a canonical empty function that can be |
| 8470 // gotten from the native context. | 8475 // gotten from the native context. |
| 8471 function = isolate->context()->native_context()->closure(); | 8476 function = isolate->context()->native_context()->closure(); |
| 8472 } else { | 8477 } else { |
| 8473 function = JSFunction::cast(args[1]); | 8478 function = JSFunction::cast(args[1]); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8728 } | 8733 } |
| 8729 } | 8734 } |
| 8730 | 8735 |
| 8731 // Otherwise, if the slot was found the holder is a context extension | 8736 // Otherwise, if the slot was found the holder is a context extension |
| 8732 // object, subject of a with, or a global object. We read the named | 8737 // object, subject of a with, or a global object. We read the named |
| 8733 // property from it. | 8738 // property from it. |
| 8734 if (!holder.is_null()) { | 8739 if (!holder.is_null()) { |
| 8735 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 8740 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
| 8736 ASSERT(object->HasProperty(*name)); | 8741 ASSERT(object->HasProperty(*name)); |
| 8737 // GetProperty below can cause GC. | 8742 // GetProperty below can cause GC. |
| 8738 Handle<Object> receiver_handle(object->IsGlobalObject() | 8743 Handle<Object> receiver_handle( |
| 8744 object->IsGlobalObject() | |
| 8739 ? GlobalObject::cast(*object)->global_receiver() | 8745 ? GlobalObject::cast(*object)->global_receiver() |
|
Michael Starzinger
2013/02/25 10:50:58
Can we indent line three and four here?
Sven Panne
2013/02/25 14:44:43
Done.
| |
| 8740 : ComputeReceiverForNonGlobal(isolate, *object)); | 8746 : ComputeReceiverForNonGlobal(isolate, *object), |
| 8747 isolate); | |
| 8741 | 8748 |
| 8742 // No need to unhole the value here. This is taken care of by the | 8749 // No need to unhole the value here. This is taken care of by the |
| 8743 // GetProperty function. | 8750 // GetProperty function. |
| 8744 MaybeObject* value = object->GetProperty(*name); | 8751 MaybeObject* value = object->GetProperty(*name); |
| 8745 return MakePair(value, *receiver_handle); | 8752 return MakePair(value, *receiver_handle); |
| 8746 } | 8753 } |
| 8747 | 8754 |
| 8748 if (throw_error) { | 8755 if (throw_error) { |
| 8749 // The property doesn't exist - throw exception. | 8756 // The property doesn't exist - throw exception. |
| 8750 Handle<Object> reference_error = | 8757 Handle<Object> reference_error = |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8896 "not_date_object", HandleVector<Object>(NULL, 0))); | 8903 "not_date_object", HandleVector<Object>(NULL, 0))); |
| 8897 } | 8904 } |
| 8898 | 8905 |
| 8899 | 8906 |
| 8900 | 8907 |
| 8901 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { | 8908 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { |
| 8902 ASSERT(args.length() == 0); | 8909 ASSERT(args.length() == 0); |
| 8903 | 8910 |
| 8904 // First check if this is a real stack overflow. | 8911 // First check if this is a real stack overflow. |
| 8905 if (isolate->stack_guard()->IsStackOverflow()) { | 8912 if (isolate->stack_guard()->IsStackOverflow()) { |
| 8906 NoHandleAllocation na; | 8913 NoHandleAllocation na(isolate); |
| 8907 return isolate->StackOverflow(); | 8914 return isolate->StackOverflow(); |
| 8908 } | 8915 } |
| 8909 | 8916 |
| 8910 return Execution::HandleStackGuardInterrupt(isolate); | 8917 return Execution::HandleStackGuardInterrupt(isolate); |
| 8911 } | 8918 } |
| 8912 | 8919 |
| 8913 | 8920 |
| 8914 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { | 8921 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { |
| 8915 ASSERT(args.length() == 0); | 8922 ASSERT(args.length() == 0); |
| 8916 return Execution::HandleStackGuardInterrupt(isolate); | 8923 return Execution::HandleStackGuardInterrupt(isolate); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 8941 // function result | 8948 // function result |
| 8942 PrintF("} -> "); | 8949 PrintF("} -> "); |
| 8943 result->ShortPrint(); | 8950 result->ShortPrint(); |
| 8944 PrintF("\n"); | 8951 PrintF("\n"); |
| 8945 } | 8952 } |
| 8946 } | 8953 } |
| 8947 | 8954 |
| 8948 | 8955 |
| 8949 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { | 8956 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { |
| 8950 ASSERT(args.length() == 0); | 8957 ASSERT(args.length() == 0); |
| 8951 NoHandleAllocation ha; | 8958 NoHandleAllocation ha(isolate); |
| 8952 PrintTransition(isolate, NULL); | 8959 PrintTransition(isolate, NULL); |
| 8953 return isolate->heap()->undefined_value(); | 8960 return isolate->heap()->undefined_value(); |
| 8954 } | 8961 } |
| 8955 | 8962 |
| 8956 | 8963 |
| 8957 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { | 8964 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { |
| 8958 NoHandleAllocation ha; | 8965 NoHandleAllocation ha(isolate); |
| 8959 PrintTransition(isolate, args[0]); | 8966 PrintTransition(isolate, args[0]); |
| 8960 return args[0]; // return TOS | 8967 return args[0]; // return TOS |
| 8961 } | 8968 } |
| 8962 | 8969 |
| 8963 | 8970 |
| 8964 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { | 8971 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { |
| 8965 NoHandleAllocation ha; | 8972 NoHandleAllocation ha(isolate); |
| 8966 ASSERT(args.length() == 1); | 8973 ASSERT(args.length() == 1); |
| 8967 | 8974 |
| 8968 #ifdef DEBUG | 8975 #ifdef DEBUG |
| 8969 if (args[0]->IsString()) { | 8976 if (args[0]->IsString()) { |
| 8970 // If we have a string, assume it's a code "marker" | 8977 // If we have a string, assume it's a code "marker" |
| 8971 // and print some interesting cpu debugging info. | 8978 // and print some interesting cpu debugging info. |
| 8972 JavaScriptFrameIterator it(isolate); | 8979 JavaScriptFrameIterator it(isolate); |
| 8973 JavaScriptFrame* frame = it.frame(); | 8980 JavaScriptFrame* frame = it.frame(); |
| 8974 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 8981 PrintF("fp = %p, sp = %p, caller_sp = %p: ", |
| 8975 frame->fp(), frame->sp(), frame->caller_sp()); | 8982 frame->fp(), frame->sp(), frame->caller_sp()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 8987 #endif | 8994 #endif |
| 8988 PrintF("\n"); | 8995 PrintF("\n"); |
| 8989 Flush(); | 8996 Flush(); |
| 8990 | 8997 |
| 8991 return args[0]; // return TOS | 8998 return args[0]; // return TOS |
| 8992 } | 8999 } |
| 8993 | 9000 |
| 8994 | 9001 |
| 8995 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { | 9002 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { |
| 8996 ASSERT(args.length() == 0); | 9003 ASSERT(args.length() == 0); |
| 8997 NoHandleAllocation ha; | 9004 NoHandleAllocation ha(isolate); |
| 8998 isolate->PrintStack(); | 9005 isolate->PrintStack(); |
| 8999 return isolate->heap()->undefined_value(); | 9006 return isolate->heap()->undefined_value(); |
| 9000 } | 9007 } |
| 9001 | 9008 |
| 9002 | 9009 |
| 9003 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 9010 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { |
| 9004 NoHandleAllocation ha; | 9011 NoHandleAllocation ha(isolate); |
| 9005 ASSERT(args.length() == 0); | 9012 ASSERT(args.length() == 0); |
| 9006 | 9013 |
| 9007 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9014 // According to ECMA-262, section 15.9.1, page 117, the precision of |
| 9008 // the number in a Date object representing a particular instant in | 9015 // the number in a Date object representing a particular instant in |
| 9009 // time is milliseconds. Therefore, we floor the result of getting | 9016 // time is milliseconds. Therefore, we floor the result of getting |
| 9010 // the OS time. | 9017 // the OS time. |
| 9011 double millis = floor(OS::TimeCurrentMillis()); | 9018 double millis = floor(OS::TimeCurrentMillis()); |
| 9012 return isolate->heap()->NumberFromDouble(millis); | 9019 return isolate->heap()->NumberFromDouble(millis); |
| 9013 } | 9020 } |
| 9014 | 9021 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9046 | 9053 |
| 9047 if (result) { | 9054 if (result) { |
| 9048 return *output; | 9055 return *output; |
| 9049 } else { | 9056 } else { |
| 9050 return isolate->heap()->null_value(); | 9057 return isolate->heap()->null_value(); |
| 9051 } | 9058 } |
| 9052 } | 9059 } |
| 9053 | 9060 |
| 9054 | 9061 |
| 9055 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9062 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
| 9056 NoHandleAllocation ha; | 9063 NoHandleAllocation ha(isolate); |
| 9057 ASSERT(args.length() == 1); | 9064 ASSERT(args.length() == 1); |
| 9058 | 9065 |
| 9059 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9066 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9060 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); | 9067 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); |
| 9061 const char* zone = OS::LocalTimezone(static_cast<double>(time)); | 9068 const char* zone = OS::LocalTimezone(static_cast<double>(time)); |
| 9062 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); | 9069 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); |
| 9063 } | 9070 } |
| 9064 | 9071 |
| 9065 | 9072 |
| 9066 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9073 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
| 9067 NoHandleAllocation ha; | 9074 NoHandleAllocation ha(isolate); |
| 9068 ASSERT(args.length() == 1); | 9075 ASSERT(args.length() == 1); |
| 9069 | 9076 |
| 9070 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9077 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9071 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9078 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
| 9072 | 9079 |
| 9073 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); | 9080 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); |
| 9074 } | 9081 } |
| 9075 | 9082 |
| 9076 | 9083 |
| 9077 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 9084 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9362 // Convert storage to dictionary mode. | 9369 // Convert storage to dictionary mode. |
| 9363 void SetDictionaryMode(uint32_t index) { | 9370 void SetDictionaryMode(uint32_t index) { |
| 9364 ASSERT(fast_elements_); | 9371 ASSERT(fast_elements_); |
| 9365 Handle<FixedArray> current_storage(*storage_); | 9372 Handle<FixedArray> current_storage(*storage_); |
| 9366 Handle<SeededNumberDictionary> slow_storage( | 9373 Handle<SeededNumberDictionary> slow_storage( |
| 9367 isolate_->factory()->NewSeededNumberDictionary( | 9374 isolate_->factory()->NewSeededNumberDictionary( |
| 9368 current_storage->length())); | 9375 current_storage->length())); |
| 9369 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); | 9376 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); |
| 9370 for (uint32_t i = 0; i < current_length; i++) { | 9377 for (uint32_t i = 0; i < current_length; i++) { |
| 9371 HandleScope loop_scope(isolate_); | 9378 HandleScope loop_scope(isolate_); |
| 9372 Handle<Object> element(current_storage->get(i)); | 9379 Handle<Object> element(current_storage->get(i), isolate_); |
| 9373 if (!element->IsTheHole()) { | 9380 if (!element->IsTheHole()) { |
| 9374 Handle<SeededNumberDictionary> new_storage = | 9381 Handle<SeededNumberDictionary> new_storage = |
| 9375 isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element); | 9382 isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element); |
| 9376 if (!new_storage.is_identical_to(slow_storage)) { | 9383 if (!new_storage.is_identical_to(slow_storage)) { |
| 9377 slow_storage = loop_scope.CloseAndEscape(new_storage); | 9384 slow_storage = loop_scope.CloseAndEscape(new_storage); |
| 9378 } | 9385 } |
| 9379 } | 9386 } |
| 9380 } | 9387 } |
| 9381 clear_storage(); | 9388 clear_storage(); |
| 9382 set_storage(*slow_storage); | 9389 set_storage(*slow_storage); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9435 for (int i = 0; i < fast_length; i++) { | 9442 for (int i = 0; i < fast_length; i++) { |
| 9436 if (!elements->is_the_hole(i)) element_count++; | 9443 if (!elements->is_the_hole(i)) element_count++; |
| 9437 } | 9444 } |
| 9438 break; | 9445 break; |
| 9439 } | 9446 } |
| 9440 case DICTIONARY_ELEMENTS: { | 9447 case DICTIONARY_ELEMENTS: { |
| 9441 Handle<SeededNumberDictionary> dictionary( | 9448 Handle<SeededNumberDictionary> dictionary( |
| 9442 SeededNumberDictionary::cast(array->elements())); | 9449 SeededNumberDictionary::cast(array->elements())); |
| 9443 int capacity = dictionary->Capacity(); | 9450 int capacity = dictionary->Capacity(); |
| 9444 for (int i = 0; i < capacity; i++) { | 9451 for (int i = 0; i < capacity; i++) { |
| 9445 Handle<Object> key(dictionary->KeyAt(i)); | 9452 Handle<Object> key(dictionary->KeyAt(i), array->GetIsolate()); |
| 9446 if (dictionary->IsKey(*key)) { | 9453 if (dictionary->IsKey(*key)) { |
| 9447 element_count++; | 9454 element_count++; |
| 9448 } | 9455 } |
| 9449 } | 9456 } |
| 9450 break; | 9457 break; |
| 9451 } | 9458 } |
| 9452 case NON_STRICT_ARGUMENTS_ELEMENTS: | 9459 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 9453 case EXTERNAL_BYTE_ELEMENTS: | 9460 case EXTERNAL_BYTE_ELEMENTS: |
| 9454 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 9461 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 9455 case EXTERNAL_SHORT_ELEMENTS: | 9462 case EXTERNAL_SHORT_ELEMENTS: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 9477 ArrayConcatVisitor* visitor) { | 9484 ArrayConcatVisitor* visitor) { |
| 9478 Handle<ExternalArrayClass> array( | 9485 Handle<ExternalArrayClass> array( |
| 9479 ExternalArrayClass::cast(receiver->elements())); | 9486 ExternalArrayClass::cast(receiver->elements())); |
| 9480 uint32_t len = static_cast<uint32_t>(array->length()); | 9487 uint32_t len = static_cast<uint32_t>(array->length()); |
| 9481 | 9488 |
| 9482 ASSERT(visitor != NULL); | 9489 ASSERT(visitor != NULL); |
| 9483 if (elements_are_ints) { | 9490 if (elements_are_ints) { |
| 9484 if (elements_are_guaranteed_smis) { | 9491 if (elements_are_guaranteed_smis) { |
| 9485 for (uint32_t j = 0; j < len; j++) { | 9492 for (uint32_t j = 0; j < len; j++) { |
| 9486 HandleScope loop_scope(isolate); | 9493 HandleScope loop_scope(isolate); |
| 9487 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j)))); | 9494 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))), |
| 9495 isolate); | |
| 9488 visitor->visit(j, e); | 9496 visitor->visit(j, e); |
| 9489 } | 9497 } |
| 9490 } else { | 9498 } else { |
| 9491 for (uint32_t j = 0; j < len; j++) { | 9499 for (uint32_t j = 0; j < len; j++) { |
| 9492 HandleScope loop_scope(isolate); | 9500 HandleScope loop_scope(isolate); |
| 9493 int64_t val = static_cast<int64_t>(array->get_scalar(j)); | 9501 int64_t val = static_cast<int64_t>(array->get_scalar(j)); |
| 9494 if (Smi::IsValid(static_cast<intptr_t>(val))) { | 9502 if (Smi::IsValid(static_cast<intptr_t>(val))) { |
| 9495 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); | 9503 Handle<Smi> e(Smi::FromInt(static_cast<int>(val)), isolate); |
| 9496 visitor->visit(j, e); | 9504 visitor->visit(j, e); |
| 9497 } else { | 9505 } else { |
| 9498 Handle<Object> e = | 9506 Handle<Object> e = |
| 9499 isolate->factory()->NewNumber(static_cast<ElementType>(val)); | 9507 isolate->factory()->NewNumber(static_cast<ElementType>(val)); |
| 9500 visitor->visit(j, e); | 9508 visitor->visit(j, e); |
| 9501 } | 9509 } |
| 9502 } | 9510 } |
| 9503 } | 9511 } |
| 9504 } else { | 9512 } else { |
| 9505 for (uint32_t j = 0; j < len; j++) { | 9513 for (uint32_t j = 0; j < len; j++) { |
| 9506 HandleScope loop_scope(isolate); | 9514 HandleScope loop_scope(isolate); |
| 9507 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); | 9515 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); |
| 9508 visitor->visit(j, e); | 9516 visitor->visit(j, e); |
| 9509 } | 9517 } |
| 9510 } | 9518 } |
| 9511 } | 9519 } |
| 9512 | 9520 |
| 9513 | 9521 |
| 9514 // Used for sorting indices in a List<uint32_t>. | 9522 // Used for sorting indices in a List<uint32_t>. |
| 9515 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { | 9523 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { |
| 9516 uint32_t a = *ap; | 9524 uint32_t a = *ap; |
| 9517 uint32_t b = *bp; | 9525 uint32_t b = *bp; |
| 9518 return (a == b) ? 0 : (a < b) ? -1 : 1; | 9526 return (a == b) ? 0 : (a < b) ? -1 : 1; |
| 9519 } | 9527 } |
| 9520 | 9528 |
| 9521 | 9529 |
| 9522 static void CollectElementIndices(Handle<JSObject> object, | 9530 static void CollectElementIndices(Handle<JSObject> object, |
| 9523 uint32_t range, | 9531 uint32_t range, |
| 9524 List<uint32_t>* indices) { | 9532 List<uint32_t>* indices) { |
| 9533 Isolate* isolate = object->GetIsolate(); | |
| 9525 ElementsKind kind = object->GetElementsKind(); | 9534 ElementsKind kind = object->GetElementsKind(); |
| 9526 switch (kind) { | 9535 switch (kind) { |
| 9527 case FAST_SMI_ELEMENTS: | 9536 case FAST_SMI_ELEMENTS: |
| 9528 case FAST_ELEMENTS: | 9537 case FAST_ELEMENTS: |
| 9529 case FAST_HOLEY_SMI_ELEMENTS: | 9538 case FAST_HOLEY_SMI_ELEMENTS: |
| 9530 case FAST_HOLEY_ELEMENTS: { | 9539 case FAST_HOLEY_ELEMENTS: { |
| 9531 Handle<FixedArray> elements(FixedArray::cast(object->elements())); | 9540 Handle<FixedArray> elements(FixedArray::cast(object->elements())); |
| 9532 uint32_t length = static_cast<uint32_t>(elements->length()); | 9541 uint32_t length = static_cast<uint32_t>(elements->length()); |
| 9533 if (range < length) length = range; | 9542 if (range < length) length = range; |
| 9534 for (uint32_t i = 0; i < length; i++) { | 9543 for (uint32_t i = 0; i < length; i++) { |
| 9535 if (!elements->get(i)->IsTheHole()) { | 9544 if (!elements->get(i)->IsTheHole()) { |
| 9536 indices->Add(i); | 9545 indices->Add(i); |
| 9537 } | 9546 } |
| 9538 } | 9547 } |
| 9539 break; | 9548 break; |
| 9540 } | 9549 } |
| 9541 case FAST_HOLEY_DOUBLE_ELEMENTS: | 9550 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 9542 case FAST_DOUBLE_ELEMENTS: { | 9551 case FAST_DOUBLE_ELEMENTS: { |
| 9543 // TODO(1810): Decide if it's worthwhile to implement this. | 9552 // TODO(1810): Decide if it's worthwhile to implement this. |
| 9544 UNREACHABLE(); | 9553 UNREACHABLE(); |
| 9545 break; | 9554 break; |
| 9546 } | 9555 } |
| 9547 case DICTIONARY_ELEMENTS: { | 9556 case DICTIONARY_ELEMENTS: { |
| 9548 Handle<SeededNumberDictionary> dict( | 9557 Handle<SeededNumberDictionary> dict( |
| 9549 SeededNumberDictionary::cast(object->elements())); | 9558 SeededNumberDictionary::cast(object->elements())); |
| 9550 uint32_t capacity = dict->Capacity(); | 9559 uint32_t capacity = dict->Capacity(); |
| 9551 for (uint32_t j = 0; j < capacity; j++) { | 9560 for (uint32_t j = 0; j < capacity; j++) { |
| 9552 HandleScope loop_scope(object->GetIsolate()); | 9561 HandleScope loop_scope(isolate); |
| 9553 Handle<Object> k(dict->KeyAt(j)); | 9562 Handle<Object> k(dict->KeyAt(j), isolate); |
| 9554 if (dict->IsKey(*k)) { | 9563 if (dict->IsKey(*k)) { |
| 9555 ASSERT(k->IsNumber()); | 9564 ASSERT(k->IsNumber()); |
| 9556 uint32_t index = static_cast<uint32_t>(k->Number()); | 9565 uint32_t index = static_cast<uint32_t>(k->Number()); |
| 9557 if (index < range) { | 9566 if (index < range) { |
| 9558 indices->Add(index); | 9567 indices->Add(index); |
| 9559 } | 9568 } |
| 9560 } | 9569 } |
| 9561 } | 9570 } |
| 9562 break; | 9571 break; |
| 9563 } | 9572 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9622 indices->Clear(); | 9631 indices->Clear(); |
| 9623 } | 9632 } |
| 9624 for (uint32_t i = 0; i < length; i++) { | 9633 for (uint32_t i = 0; i < length; i++) { |
| 9625 indices->Add(i); | 9634 indices->Add(i); |
| 9626 } | 9635 } |
| 9627 if (length == range) return; // All indices accounted for already. | 9636 if (length == range) return; // All indices accounted for already. |
| 9628 break; | 9637 break; |
| 9629 } | 9638 } |
| 9630 } | 9639 } |
| 9631 | 9640 |
| 9632 Handle<Object> prototype(object->GetPrototype()); | 9641 Handle<Object> prototype(object->GetPrototype(), isolate); |
| 9633 if (prototype->IsJSObject()) { | 9642 if (prototype->IsJSObject()) { |
| 9634 // The prototype will usually have no inherited element indices, | 9643 // The prototype will usually have no inherited element indices, |
| 9635 // but we have to check. | 9644 // but we have to check. |
| 9636 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices); | 9645 CollectElementIndices(Handle<JSObject>::cast(prototype), range, indices); |
| 9637 } | 9646 } |
| 9638 } | 9647 } |
| 9639 | 9648 |
| 9640 | 9649 |
| 9641 /** | 9650 /** |
| 9642 * A helper function that visits elements of a JSArray in numerical | 9651 * A helper function that visits elements of a JSArray in numerical |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9721 do { | 9730 do { |
| 9722 j++; | 9731 j++; |
| 9723 } while (j < n && indices[j] == index); | 9732 } while (j < n && indices[j] == index); |
| 9724 } | 9733 } |
| 9725 break; | 9734 break; |
| 9726 } | 9735 } |
| 9727 case EXTERNAL_PIXEL_ELEMENTS: { | 9736 case EXTERNAL_PIXEL_ELEMENTS: { |
| 9728 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( | 9737 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( |
| 9729 receiver->elements())); | 9738 receiver->elements())); |
| 9730 for (uint32_t j = 0; j < length; j++) { | 9739 for (uint32_t j = 0; j < length; j++) { |
| 9731 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j))); | 9740 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j)), isolate); |
| 9732 visitor->visit(j, e); | 9741 visitor->visit(j, e); |
| 9733 } | 9742 } |
| 9734 break; | 9743 break; |
| 9735 } | 9744 } |
| 9736 case EXTERNAL_BYTE_ELEMENTS: { | 9745 case EXTERNAL_BYTE_ELEMENTS: { |
| 9737 IterateExternalArrayElements<ExternalByteArray, int8_t>( | 9746 IterateExternalArrayElements<ExternalByteArray, int8_t>( |
| 9738 isolate, receiver, true, true, visitor); | 9747 isolate, receiver, true, true, visitor); |
| 9739 break; | 9748 break; |
| 9740 } | 9749 } |
| 9741 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 9750 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9801 // The actual length can be larger if any of the arguments have getters | 9810 // The actual length can be larger if any of the arguments have getters |
| 9802 // that mutate other arguments (but will otherwise be precise). | 9811 // that mutate other arguments (but will otherwise be precise). |
| 9803 // The number of elements is precise if there are no inherited elements. | 9812 // The number of elements is precise if there are no inherited elements. |
| 9804 | 9813 |
| 9805 ElementsKind kind = FAST_SMI_ELEMENTS; | 9814 ElementsKind kind = FAST_SMI_ELEMENTS; |
| 9806 | 9815 |
| 9807 uint32_t estimate_result_length = 0; | 9816 uint32_t estimate_result_length = 0; |
| 9808 uint32_t estimate_nof_elements = 0; | 9817 uint32_t estimate_nof_elements = 0; |
| 9809 for (int i = 0; i < argument_count; i++) { | 9818 for (int i = 0; i < argument_count; i++) { |
| 9810 HandleScope loop_scope(isolate); | 9819 HandleScope loop_scope(isolate); |
| 9811 Handle<Object> obj(elements->get(i)); | 9820 Handle<Object> obj(elements->get(i), isolate); |
| 9812 uint32_t length_estimate; | 9821 uint32_t length_estimate; |
| 9813 uint32_t element_estimate; | 9822 uint32_t element_estimate; |
| 9814 if (obj->IsJSArray()) { | 9823 if (obj->IsJSArray()) { |
| 9815 Handle<JSArray> array(Handle<JSArray>::cast(obj)); | 9824 Handle<JSArray> array(Handle<JSArray>::cast(obj)); |
| 9816 length_estimate = static_cast<uint32_t>(array->length()->Number()); | 9825 length_estimate = static_cast<uint32_t>(array->length()->Number()); |
| 9817 if (length_estimate != 0) { | 9826 if (length_estimate != 0) { |
| 9818 ElementsKind array_kind = | 9827 ElementsKind array_kind = |
| 9819 GetPackedElementsKind(array->map()->elements_kind()); | 9828 GetPackedElementsKind(array->map()->elements_kind()); |
| 9820 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) { | 9829 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) { |
| 9821 kind = array_kind; | 9830 kind = array_kind; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9856 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length; | 9865 bool fast_case = (estimate_nof_elements * 2) >= estimate_result_length; |
| 9857 | 9866 |
| 9858 Handle<FixedArray> storage; | 9867 Handle<FixedArray> storage; |
| 9859 if (fast_case) { | 9868 if (fast_case) { |
| 9860 if (kind == FAST_DOUBLE_ELEMENTS) { | 9869 if (kind == FAST_DOUBLE_ELEMENTS) { |
| 9861 Handle<FixedDoubleArray> double_storage = | 9870 Handle<FixedDoubleArray> double_storage = |
| 9862 isolate->factory()->NewFixedDoubleArray(estimate_result_length); | 9871 isolate->factory()->NewFixedDoubleArray(estimate_result_length); |
| 9863 int j = 0; | 9872 int j = 0; |
| 9864 bool failure = false; | 9873 bool failure = false; |
| 9865 for (int i = 0; i < argument_count; i++) { | 9874 for (int i = 0; i < argument_count; i++) { |
| 9866 Handle<Object> obj(elements->get(i)); | 9875 Handle<Object> obj(elements->get(i), isolate); |
| 9867 if (obj->IsSmi()) { | 9876 if (obj->IsSmi()) { |
| 9868 double_storage->set(j, Smi::cast(*obj)->value()); | 9877 double_storage->set(j, Smi::cast(*obj)->value()); |
| 9869 j++; | 9878 j++; |
| 9870 } else if (obj->IsNumber()) { | 9879 } else if (obj->IsNumber()) { |
| 9871 double_storage->set(j, obj->Number()); | 9880 double_storage->set(j, obj->Number()); |
| 9872 j++; | 9881 j++; |
| 9873 } else { | 9882 } else { |
| 9874 JSArray* array = JSArray::cast(*obj); | 9883 JSArray* array = JSArray::cast(*obj); |
| 9875 uint32_t length = static_cast<uint32_t>(array->length()->Number()); | 9884 uint32_t length = static_cast<uint32_t>(array->length()->Number()); |
| 9876 switch (array->map()->elements_kind()) { | 9885 switch (array->map()->elements_kind()) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9933 // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate | 9942 // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate |
| 9934 uint32_t at_least_space_for = estimate_nof_elements + | 9943 uint32_t at_least_space_for = estimate_nof_elements + |
| 9935 (estimate_nof_elements >> 2); | 9944 (estimate_nof_elements >> 2); |
| 9936 storage = Handle<FixedArray>::cast( | 9945 storage = Handle<FixedArray>::cast( |
| 9937 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); | 9946 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); |
| 9938 } | 9947 } |
| 9939 | 9948 |
| 9940 ArrayConcatVisitor visitor(isolate, storage, fast_case); | 9949 ArrayConcatVisitor visitor(isolate, storage, fast_case); |
| 9941 | 9950 |
| 9942 for (int i = 0; i < argument_count; i++) { | 9951 for (int i = 0; i < argument_count; i++) { |
| 9943 Handle<Object> obj(elements->get(i)); | 9952 Handle<Object> obj(elements->get(i), isolate); |
| 9944 if (obj->IsJSArray()) { | 9953 if (obj->IsJSArray()) { |
| 9945 Handle<JSArray> array = Handle<JSArray>::cast(obj); | 9954 Handle<JSArray> array = Handle<JSArray>::cast(obj); |
| 9946 if (!IterateElements(isolate, array, &visitor)) { | 9955 if (!IterateElements(isolate, array, &visitor)) { |
| 9947 return Failure::Exception(); | 9956 return Failure::Exception(); |
| 9948 } | 9957 } |
| 9949 } else { | 9958 } else { |
| 9950 visitor.visit(0, obj); | 9959 visitor.visit(0, obj); |
| 9951 visitor.increase_index_offset(1); | 9960 visitor.increase_index_offset(1); |
| 9952 } | 9961 } |
| 9953 } | 9962 } |
| 9954 | 9963 |
| 9955 return *visitor.ToArray(); | 9964 return *visitor.ToArray(); |
| 9956 } | 9965 } |
| 9957 | 9966 |
| 9958 | 9967 |
| 9959 // This will not allocate (flatten the string), but it may run | 9968 // This will not allocate (flatten the string), but it may run |
| 9960 // very slowly for very deeply nested ConsStrings. For debugging use only. | 9969 // very slowly for very deeply nested ConsStrings. For debugging use only. |
| 9961 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { | 9970 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { |
| 9962 NoHandleAllocation ha; | 9971 NoHandleAllocation ha(isolate); |
| 9963 ASSERT(args.length() == 1); | 9972 ASSERT(args.length() == 1); |
| 9964 | 9973 |
| 9965 CONVERT_ARG_CHECKED(String, string, 0); | 9974 CONVERT_ARG_CHECKED(String, string, 0); |
| 9966 ConsStringIteratorOp op; | 9975 ConsStringIteratorOp op; |
| 9967 StringCharacterStream stream(string, &op); | 9976 StringCharacterStream stream(string, &op); |
| 9968 while (stream.HasMore()) { | 9977 while (stream.HasMore()) { |
| 9969 uint16_t character = stream.GetNext(); | 9978 uint16_t character = stream.GetNext(); |
| 9970 PrintF("%c", character); | 9979 PrintF("%c", character); |
| 9971 } | 9980 } |
| 9972 return string; | 9981 return string; |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10804 Handle<SharedFunctionInfo> shared(function->shared()); | 10813 Handle<SharedFunctionInfo> shared(function->shared()); |
| 10805 Handle<ScopeInfo> scope_info(shared->scope_info()); | 10814 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 10806 | 10815 |
| 10807 // Allocate and initialize a JSObject with all the arguments, stack locals | 10816 // Allocate and initialize a JSObject with all the arguments, stack locals |
| 10808 // heap locals and extension properties of the debugged function. | 10817 // heap locals and extension properties of the debugged function. |
| 10809 Handle<JSObject> local_scope = | 10818 Handle<JSObject> local_scope = |
| 10810 isolate->factory()->NewJSObject(isolate->object_function()); | 10819 isolate->factory()->NewJSObject(isolate->object_function()); |
| 10811 | 10820 |
| 10812 // First fill all parameters. | 10821 // First fill all parameters. |
| 10813 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 10822 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 10814 Handle<Object> value( | 10823 Handle<Object> value(i < frame_inspector->GetParametersCount() |
| 10815 i < frame_inspector->GetParametersCount() ? | 10824 ? frame_inspector->GetParameter(i) |
|
Michael Starzinger
2013/02/25 10:50:58
Can we indent line two and three here?
Sven Panne
2013/02/25 14:44:43
Done.
| |
| 10816 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value()); | 10825 : isolate->heap()->undefined_value(), |
| 10826 isolate); | |
| 10817 | 10827 |
| 10818 RETURN_IF_EMPTY_HANDLE_VALUE( | 10828 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 10819 isolate, | 10829 isolate, |
| 10820 SetProperty(isolate, | 10830 SetProperty(isolate, |
| 10821 local_scope, | 10831 local_scope, |
| 10822 Handle<String>(scope_info->ParameterName(i)), | 10832 Handle<String>(scope_info->ParameterName(i)), |
| 10823 value, | 10833 value, |
| 10824 NONE, | 10834 NONE, |
| 10825 kNonStrictMode), | 10835 kNonStrictMode), |
| 10826 Handle<JSObject>()); | 10836 Handle<JSObject>()); |
| 10827 } | 10837 } |
| 10828 | 10838 |
| 10829 // Second fill all stack locals. | 10839 // Second fill all stack locals. |
| 10830 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 10840 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 10831 RETURN_IF_EMPTY_HANDLE_VALUE( | 10841 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 10832 isolate, | 10842 isolate, |
| 10833 SetProperty(isolate, | 10843 SetProperty(isolate, |
| 10834 local_scope, | 10844 local_scope, |
| 10835 Handle<String>(scope_info->StackLocalName(i)), | 10845 Handle<String>(scope_info->StackLocalName(i)), |
| 10836 Handle<Object>(frame_inspector->GetExpression(i)), | 10846 Handle<Object>(frame_inspector->GetExpression(i), isolate), |
| 10837 NONE, | 10847 NONE, |
| 10838 kNonStrictMode), | 10848 kNonStrictMode), |
| 10839 Handle<JSObject>()); | 10849 Handle<JSObject>()); |
| 10840 } | 10850 } |
| 10841 | 10851 |
| 10842 if (scope_info->HasContext()) { | 10852 if (scope_info->HasContext()) { |
| 10843 // Third fill all context locals. | 10853 // Third fill all context locals. |
| 10844 Handle<Context> frame_context(Context::cast(frame->context())); | 10854 Handle<Context> frame_context(Context::cast(frame->context())); |
| 10845 Handle<Context> function_context(frame_context->declaration_context()); | 10855 Handle<Context> function_context(frame_context->declaration_context()); |
| 10846 if (!CopyContextLocalsToScopeObject( | 10856 if (!CopyContextLocalsToScopeObject( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 10861 | 10871 |
| 10862 for (int i = 0; i < keys->length(); i++) { | 10872 for (int i = 0; i < keys->length(); i++) { |
| 10863 // Names of variables introduced by eval are strings. | 10873 // Names of variables introduced by eval are strings. |
| 10864 ASSERT(keys->get(i)->IsString()); | 10874 ASSERT(keys->get(i)->IsString()); |
| 10865 Handle<String> key(String::cast(keys->get(i))); | 10875 Handle<String> key(String::cast(keys->get(i))); |
| 10866 RETURN_IF_EMPTY_HANDLE_VALUE( | 10876 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 10867 isolate, | 10877 isolate, |
| 10868 SetProperty(isolate, | 10878 SetProperty(isolate, |
| 10869 local_scope, | 10879 local_scope, |
| 10870 key, | 10880 key, |
| 10871 GetProperty(ext, key), | 10881 GetProperty(isolate, ext, key), |
| 10872 NONE, | 10882 NONE, |
| 10873 kNonStrictMode), | 10883 kNonStrictMode), |
| 10874 Handle<JSObject>()); | 10884 Handle<JSObject>()); |
| 10875 } | 10885 } |
| 10876 } | 10886 } |
| 10877 } | 10887 } |
| 10878 } | 10888 } |
| 10879 | 10889 |
| 10880 return local_scope; | 10890 return local_scope; |
| 10881 } | 10891 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11012 | 11022 |
| 11013 for (int i = 0; i < keys->length(); i++) { | 11023 for (int i = 0; i < keys->length(); i++) { |
| 11014 // Names of variables introduced by eval are strings. | 11024 // Names of variables introduced by eval are strings. |
| 11015 ASSERT(keys->get(i)->IsString()); | 11025 ASSERT(keys->get(i)->IsString()); |
| 11016 Handle<String> key(String::cast(keys->get(i))); | 11026 Handle<String> key(String::cast(keys->get(i))); |
| 11017 RETURN_IF_EMPTY_HANDLE_VALUE( | 11027 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 11018 isolate, | 11028 isolate, |
| 11019 SetProperty(isolate, | 11029 SetProperty(isolate, |
| 11020 closure_scope, | 11030 closure_scope, |
| 11021 key, | 11031 key, |
| 11022 GetProperty(ext, key), | 11032 GetProperty(isolate, ext, key), |
| 11023 NONE, | 11033 NONE, |
| 11024 kNonStrictMode), | 11034 kNonStrictMode), |
| 11025 Handle<JSObject>()); | 11035 Handle<JSObject>()); |
| 11026 } | 11036 } |
| 11027 } | 11037 } |
| 11028 | 11038 |
| 11029 return closure_scope; | 11039 return closure_scope; |
| 11030 } | 11040 } |
| 11031 | 11041 |
| 11032 | 11042 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11065 return false; | 11075 return false; |
| 11066 } | 11076 } |
| 11067 | 11077 |
| 11068 | 11078 |
| 11069 // Create a plain JSObject which materializes the scope for the specified | 11079 // Create a plain JSObject which materializes the scope for the specified |
| 11070 // catch context. | 11080 // catch context. |
| 11071 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, | 11081 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, |
| 11072 Handle<Context> context) { | 11082 Handle<Context> context) { |
| 11073 ASSERT(context->IsCatchContext()); | 11083 ASSERT(context->IsCatchContext()); |
| 11074 Handle<String> name(String::cast(context->extension())); | 11084 Handle<String> name(String::cast(context->extension())); |
| 11075 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX)); | 11085 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), |
| 11086 isolate); | |
| 11076 Handle<JSObject> catch_scope = | 11087 Handle<JSObject> catch_scope = |
| 11077 isolate->factory()->NewJSObject(isolate->object_function()); | 11088 isolate->factory()->NewJSObject(isolate->object_function()); |
| 11078 RETURN_IF_EMPTY_HANDLE_VALUE( | 11089 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 11079 isolate, | 11090 isolate, |
| 11080 SetProperty(isolate, | 11091 SetProperty(isolate, |
| 11081 catch_scope, | 11092 catch_scope, |
| 11082 name, | 11093 name, |
| 11083 thrown_object, | 11094 thrown_object, |
| 11084 NONE, | 11095 NONE, |
| 11085 kNonStrictMode), | 11096 kNonStrictMode), |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11422 PrintF("Global:\n"); | 11433 PrintF("Global:\n"); |
| 11423 CurrentContext()->Print(); | 11434 CurrentContext()->Print(); |
| 11424 break; | 11435 break; |
| 11425 | 11436 |
| 11426 case ScopeIterator::ScopeTypeLocal: { | 11437 case ScopeIterator::ScopeTypeLocal: { |
| 11427 PrintF("Local:\n"); | 11438 PrintF("Local:\n"); |
| 11428 function_->shared()->scope_info()->Print(); | 11439 function_->shared()->scope_info()->Print(); |
| 11429 if (!CurrentContext().is_null()) { | 11440 if (!CurrentContext().is_null()) { |
| 11430 CurrentContext()->Print(); | 11441 CurrentContext()->Print(); |
| 11431 if (CurrentContext()->has_extension()) { | 11442 if (CurrentContext()->has_extension()) { |
| 11432 Handle<Object> extension(CurrentContext()->extension()); | 11443 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
| 11433 if (extension->IsJSContextExtensionObject()) { | 11444 if (extension->IsJSContextExtensionObject()) { |
| 11434 extension->Print(); | 11445 extension->Print(); |
| 11435 } | 11446 } |
| 11436 } | 11447 } |
| 11437 } | 11448 } |
| 11438 break; | 11449 break; |
| 11439 } | 11450 } |
| 11440 | 11451 |
| 11441 case ScopeIterator::ScopeTypeWith: | 11452 case ScopeIterator::ScopeTypeWith: |
| 11442 PrintF("With:\n"); | 11453 PrintF("With:\n"); |
| 11443 CurrentContext()->extension()->Print(); | 11454 CurrentContext()->extension()->Print(); |
| 11444 break; | 11455 break; |
| 11445 | 11456 |
| 11446 case ScopeIterator::ScopeTypeCatch: | 11457 case ScopeIterator::ScopeTypeCatch: |
| 11447 PrintF("Catch:\n"); | 11458 PrintF("Catch:\n"); |
| 11448 CurrentContext()->extension()->Print(); | 11459 CurrentContext()->extension()->Print(); |
| 11449 CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(); | 11460 CurrentContext()->get(Context::THROWN_OBJECT_INDEX)->Print(); |
| 11450 break; | 11461 break; |
| 11451 | 11462 |
| 11452 case ScopeIterator::ScopeTypeClosure: | 11463 case ScopeIterator::ScopeTypeClosure: |
| 11453 PrintF("Closure:\n"); | 11464 PrintF("Closure:\n"); |
| 11454 CurrentContext()->Print(); | 11465 CurrentContext()->Print(); |
| 11455 if (CurrentContext()->has_extension()) { | 11466 if (CurrentContext()->has_extension()) { |
| 11456 Handle<Object> extension(CurrentContext()->extension()); | 11467 Handle<Object> extension(CurrentContext()->extension(), isolate_); |
| 11457 if (extension->IsJSContextExtensionObject()) { | 11468 if (extension->IsJSContextExtensionObject()) { |
| 11458 extension->Print(); | 11469 extension->Print(); |
| 11459 } | 11470 } |
| 11460 } | 11471 } |
| 11461 break; | 11472 break; |
| 11462 | 11473 |
| 11463 default: | 11474 default: |
| 11464 UNREACHABLE(); | 11475 UNREACHABLE(); |
| 11465 } | 11476 } |
| 11466 PrintF("\n"); | 11477 PrintF("\n"); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11985 Handle<Context> context = base; | 11996 Handle<Context> context = base; |
| 11986 | 11997 |
| 11987 // Iteratively copy and or materialize the nested contexts. | 11998 // Iteratively copy and or materialize the nested contexts. |
| 11988 while (!scope_chain.is_empty()) { | 11999 while (!scope_chain.is_empty()) { |
| 11989 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast(); | 12000 Handle<ScopeInfo> scope_info = scope_chain.RemoveLast(); |
| 11990 Handle<Context> current = context_chain.RemoveLast(); | 12001 Handle<Context> current = context_chain.RemoveLast(); |
| 11991 ASSERT(!(scope_info->HasContext() & current.is_null())); | 12002 ASSERT(!(scope_info->HasContext() & current.is_null())); |
| 11992 | 12003 |
| 11993 if (scope_info->Type() == CATCH_SCOPE) { | 12004 if (scope_info->Type() == CATCH_SCOPE) { |
| 11994 Handle<String> name(String::cast(current->extension())); | 12005 Handle<String> name(String::cast(current->extension())); |
| 11995 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX)); | 12006 Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX), |
| 12007 isolate); | |
| 11996 context = | 12008 context = |
| 11997 isolate->factory()->NewCatchContext(function, | 12009 isolate->factory()->NewCatchContext(function, |
| 11998 context, | 12010 context, |
| 11999 name, | 12011 name, |
| 12000 thrown_object); | 12012 thrown_object); |
| 12001 } else if (scope_info->Type() == BLOCK_SCOPE) { | 12013 } else if (scope_info->Type() == BLOCK_SCOPE) { |
| 12002 // Materialize the contents of the block scope into a JSObject. | 12014 // Materialize the contents of the block scope into a JSObject. |
| 12003 Handle<JSObject> block_scope_object = | 12015 Handle<JSObject> block_scope_object = |
| 12004 MaterializeBlockScope(isolate, current); | 12016 MaterializeBlockScope(isolate, current); |
| 12005 CHECK(!block_scope_object.is_null()); | 12017 CHECK(!block_scope_object.is_null()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12093 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 12105 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
| 12094 RUNTIME_ARGUMENTS(isolate, args)); | 12106 RUNTIME_ARGUMENTS(isolate, args)); |
| 12095 if (!maybe_check_result->ToObject(&check_result)) { | 12107 if (!maybe_check_result->ToObject(&check_result)) { |
| 12096 return maybe_check_result; | 12108 return maybe_check_result; |
| 12097 } | 12109 } |
| 12098 } | 12110 } |
| 12099 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12111 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12100 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12112 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 12101 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); | 12113 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); |
| 12102 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); | 12114 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); |
| 12103 Handle<Object> additional_context(args[5]); | 12115 Handle<Object> additional_context(args[5], isolate); |
| 12104 | 12116 |
| 12105 // Handle the processing of break. | 12117 // Handle the processing of break. |
| 12106 DisableBreak disable_break_save(disable_break); | 12118 DisableBreak disable_break_save(disable_break); |
| 12107 | 12119 |
| 12108 // Get the frame where the debugging is performed. | 12120 // Get the frame where the debugging is performed. |
| 12109 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12121 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 12110 JavaScriptFrameIterator it(isolate, id); | 12122 JavaScriptFrameIterator it(isolate, id); |
| 12111 JavaScriptFrame* frame = it.frame(); | 12123 JavaScriptFrame* frame = it.frame(); |
| 12112 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 12124 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
| 12113 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 12125 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12253 ASSERT(args.length() == 4); | 12265 ASSERT(args.length() == 4); |
| 12254 Object* check_result; | 12266 Object* check_result; |
| 12255 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( | 12267 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
| 12256 RUNTIME_ARGUMENTS(isolate, args)); | 12268 RUNTIME_ARGUMENTS(isolate, args)); |
| 12257 if (!maybe_check_result->ToObject(&check_result)) { | 12269 if (!maybe_check_result->ToObject(&check_result)) { |
| 12258 return maybe_check_result; | 12270 return maybe_check_result; |
| 12259 } | 12271 } |
| 12260 } | 12272 } |
| 12261 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 12273 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 12262 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 12274 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
| 12263 Handle<Object> additional_context(args[3]); | 12275 Handle<Object> additional_context(args[3], isolate); |
| 12264 | 12276 |
| 12265 // Handle the processing of break. | 12277 // Handle the processing of break. |
| 12266 DisableBreak disable_break_save(disable_break); | 12278 DisableBreak disable_break_save(disable_break); |
| 12267 | 12279 |
| 12268 // Enter the top context from before the debugger was invoked. | 12280 // Enter the top context from before the debugger was invoked. |
| 12269 SaveContext save(isolate); | 12281 SaveContext save(isolate); |
| 12270 SaveContext* top = &save; | 12282 SaveContext* top = &save; |
| 12271 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { | 12283 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { |
| 12272 top = top->prev(); | 12284 top = top->prev(); |
| 12273 } | 12285 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12345 return *result; | 12357 return *result; |
| 12346 } | 12358 } |
| 12347 | 12359 |
| 12348 | 12360 |
| 12349 // Helper function used by Runtime_DebugReferencedBy below. | 12361 // Helper function used by Runtime_DebugReferencedBy below. |
| 12350 static int DebugReferencedBy(HeapIterator* iterator, | 12362 static int DebugReferencedBy(HeapIterator* iterator, |
| 12351 JSObject* target, | 12363 JSObject* target, |
| 12352 Object* instance_filter, int max_references, | 12364 Object* instance_filter, int max_references, |
| 12353 FixedArray* instances, int instances_size, | 12365 FixedArray* instances, int instances_size, |
| 12354 JSFunction* arguments_function) { | 12366 JSFunction* arguments_function) { |
| 12355 NoHandleAllocation ha; | 12367 NoHandleAllocation ha(target->GetIsolate()); |
| 12356 AssertNoAllocation no_alloc; | 12368 AssertNoAllocation no_alloc; |
| 12357 | 12369 |
| 12358 // Iterate the heap. | 12370 // Iterate the heap. |
| 12359 int count = 0; | 12371 int count = 0; |
| 12360 JSObject* last = NULL; | 12372 JSObject* last = NULL; |
| 12361 HeapObject* heap_obj = NULL; | 12373 HeapObject* heap_obj = NULL; |
| 12362 while (((heap_obj = iterator->next()) != NULL) && | 12374 while (((heap_obj = iterator->next()) != NULL) && |
| 12363 (max_references == 0 || count < max_references)) { | 12375 (max_references == 0 || count < max_references)) { |
| 12364 // Only look at all JSObjects. | 12376 // Only look at all JSObjects. |
| 12365 if (heap_obj->IsJSObject()) { | 12377 if (heap_obj->IsJSObject()) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12622 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { | 12634 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { |
| 12623 return Failure::Exception(); | 12635 return Failure::Exception(); |
| 12624 } | 12636 } |
| 12625 func->shared()->construct_stub()->PrintLn(); | 12637 func->shared()->construct_stub()->PrintLn(); |
| 12626 #endif // DEBUG | 12638 #endif // DEBUG |
| 12627 return isolate->heap()->undefined_value(); | 12639 return isolate->heap()->undefined_value(); |
| 12628 } | 12640 } |
| 12629 | 12641 |
| 12630 | 12642 |
| 12631 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { | 12643 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { |
| 12632 NoHandleAllocation ha; | 12644 NoHandleAllocation ha(isolate); |
| 12633 ASSERT(args.length() == 1); | 12645 ASSERT(args.length() == 1); |
| 12634 | 12646 |
| 12635 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 12647 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 12636 return f->shared()->inferred_name(); | 12648 return f->shared()->inferred_name(); |
| 12637 } | 12649 } |
| 12638 | 12650 |
| 12639 | 12651 |
| 12640 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 12652 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
| 12641 Script* script, | 12653 Script* script, |
| 12642 FixedArray* buffer) { | 12654 FixedArray* buffer) { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12999 if (!Smi::IsValid(usage)) { | 13011 if (!Smi::IsValid(usage)) { |
| 13000 return *isolate->factory()->NewNumberFromInt(usage); | 13012 return *isolate->factory()->NewNumberFromInt(usage); |
| 13001 } | 13013 } |
| 13002 return Smi::FromInt(usage); | 13014 return Smi::FromInt(usage); |
| 13003 } | 13015 } |
| 13004 | 13016 |
| 13005 #endif // ENABLE_DEBUGGER_SUPPORT | 13017 #endif // ENABLE_DEBUGGER_SUPPORT |
| 13006 | 13018 |
| 13007 | 13019 |
| 13008 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { | 13020 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { |
| 13009 NoHandleAllocation ha; | 13021 NoHandleAllocation ha(isolate); |
| 13010 v8::V8::ResumeProfiler(); | 13022 v8::V8::ResumeProfiler(); |
| 13011 return isolate->heap()->undefined_value(); | 13023 return isolate->heap()->undefined_value(); |
| 13012 } | 13024 } |
| 13013 | 13025 |
| 13014 | 13026 |
| 13015 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { | 13027 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { |
| 13016 NoHandleAllocation ha; | 13028 NoHandleAllocation ha(isolate); |
| 13017 v8::V8::PauseProfiler(); | 13029 v8::V8::PauseProfiler(); |
| 13018 return isolate->heap()->undefined_value(); | 13030 return isolate->heap()->undefined_value(); |
| 13019 } | 13031 } |
| 13020 | 13032 |
| 13021 | 13033 |
| 13022 // Finds the script object from the script data. NOTE: This operation uses | 13034 // Finds the script object from the script data. NOTE: This operation uses |
| 13023 // heap traversal to find the function generated for the source position | 13035 // heap traversal to find the function generated for the source position |
| 13024 // for the requested break point. For lazily compiled functions several heap | 13036 // for the requested break point. For lazily compiled functions several heap |
| 13025 // traversals might be required rendering this operation as a rather slow | 13037 // traversals might be required rendering this operation as a rather slow |
| 13026 // operation. However for setting break points which is normally done through | 13038 // operation. However for setting break points which is normally done through |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13128 JSObject::SetHiddenProperty(error_object, key, value); | 13140 JSObject::SetHiddenProperty(error_object, key, value); |
| 13129 } | 13141 } |
| 13130 return *error_object; | 13142 return *error_object; |
| 13131 } | 13143 } |
| 13132 | 13144 |
| 13133 | 13145 |
| 13134 // Returns V8 version as a string. | 13146 // Returns V8 version as a string. |
| 13135 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 13147 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
| 13136 ASSERT_EQ(args.length(), 0); | 13148 ASSERT_EQ(args.length(), 0); |
| 13137 | 13149 |
| 13138 NoHandleAllocation ha; | 13150 NoHandleAllocation ha(isolate); |
| 13139 | 13151 |
| 13140 const char* version_string = v8::V8::GetVersion(); | 13152 const char* version_string = v8::V8::GetVersion(); |
| 13141 | 13153 |
| 13142 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), | 13154 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), |
| 13143 NOT_TENURED); | 13155 NOT_TENURED); |
| 13144 } | 13156 } |
| 13145 | 13157 |
| 13146 | 13158 |
| 13147 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 13159 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { |
| 13148 ASSERT(args.length() == 2); | 13160 ASSERT(args.length() == 2); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13194 if (o == key) { | 13206 if (o == key) { |
| 13195 cache->set_finger_index(i); | 13207 cache->set_finger_index(i); |
| 13196 return cache->get(i + 1); | 13208 return cache->get(i + 1); |
| 13197 } | 13209 } |
| 13198 } | 13210 } |
| 13199 | 13211 |
| 13200 // There is no value in the cache. Invoke the function and cache result. | 13212 // There is no value in the cache. Invoke the function and cache result. |
| 13201 HandleScope scope(isolate); | 13213 HandleScope scope(isolate); |
| 13202 | 13214 |
| 13203 Handle<JSFunctionResultCache> cache_handle(cache); | 13215 Handle<JSFunctionResultCache> cache_handle(cache); |
| 13204 Handle<Object> key_handle(key); | 13216 Handle<Object> key_handle(key, isolate); |
| 13205 Handle<Object> value; | 13217 Handle<Object> value; |
| 13206 { | 13218 { |
| 13207 Handle<JSFunction> factory(JSFunction::cast( | 13219 Handle<JSFunction> factory(JSFunction::cast( |
| 13208 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); | 13220 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); |
| 13209 // TODO(antonm): consider passing a receiver when constructing a cache. | 13221 // TODO(antonm): consider passing a receiver when constructing a cache. |
| 13210 Handle<Object> receiver(isolate->native_context()->global_object()); | 13222 Handle<Object> receiver(isolate->native_context()->global_object(), |
| 13223 isolate); | |
| 13211 // This handle is nor shared, nor used later, so it's safe. | 13224 // This handle is nor shared, nor used later, so it's safe. |
| 13212 Handle<Object> argv[] = { key_handle }; | 13225 Handle<Object> argv[] = { key_handle }; |
| 13213 bool pending_exception; | 13226 bool pending_exception; |
| 13214 value = Execution::Call(factory, | 13227 value = Execution::Call(factory, |
| 13215 receiver, | 13228 receiver, |
| 13216 ARRAY_SIZE(argv), | 13229 ARRAY_SIZE(argv), |
| 13217 argv, | 13230 argv, |
| 13218 &pending_exception); | 13231 &pending_exception); |
| 13219 if (pending_exception) return Failure::Exception(); | 13232 if (pending_exception) return Failure::Exception(); |
| 13220 } | 13233 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13533 // Handle last resort GC and make sure to allow future allocations | 13546 // Handle last resort GC and make sure to allow future allocations |
| 13534 // to grow the heap without causing GCs (if possible). | 13547 // to grow the heap without causing GCs (if possible). |
| 13535 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13548 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13536 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13549 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13537 "Runtime::PerformGC"); | 13550 "Runtime::PerformGC"); |
| 13538 } | 13551 } |
| 13539 } | 13552 } |
| 13540 | 13553 |
| 13541 | 13554 |
| 13542 } } // namespace v8::internal | 13555 } } // namespace v8::internal |
| OLD | NEW |