| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 Object* prototype = args[1]; | 608 Object* prototype = args[1]; |
| 609 Object* used_prototype = | 609 Object* used_prototype = |
| 610 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); | 610 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
| 611 return isolate->heap()->AllocateJSProxy(handler, used_prototype); | 611 return isolate->heap()->AllocateJSProxy(handler, used_prototype); |
| 612 } | 612 } |
| 613 | 613 |
| 614 | 614 |
| 615 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { | 615 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { |
| 616 ASSERT(args.length() == 1); | 616 ASSERT(args.length() == 1); |
| 617 Object* obj = args[0]; | 617 Object* obj = args[0]; |
| 618 return obj->IsJSProxy() | 618 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
| 619 ? isolate->heap()->true_value() : isolate->heap()->false_value(); | |
| 620 } | 619 } |
| 621 | 620 |
| 622 | 621 |
| 623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 622 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { |
| 624 ASSERT(args.length() == 1); | 623 ASSERT(args.length() == 1); |
| 625 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 624 CONVERT_CHECKED(JSProxy, proxy, args[0]); |
| 626 return proxy->handler(); | 625 return proxy->handler(); |
| 627 } | 626 } |
| 628 | 627 |
| 629 | 628 |
| 630 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { | 629 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { |
| 631 ASSERT(args.length() == 1); | 630 ASSERT(args.length() == 1); |
| 632 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 631 CONVERT_CHECKED(JSProxy, proxy, args[0]); |
| 633 proxy->Fix(); | 632 proxy->Fix(); |
| 634 return isolate->heap()->undefined_value(); | 633 return isolate->heap()->undefined_value(); |
| 635 } | 634 } |
| 636 | 635 |
| 637 | 636 |
| 637 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { |
| 638 HandleScope scope(isolate); |
| 639 ASSERT(args.length() == 1); |
| 640 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); |
| 641 ASSERT(weakmap->map()->inobject_properties() == 0); |
| 642 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| 643 weakmap->set_table(*table); |
| 644 weakmap->set_next(Smi::FromInt(0)); |
| 645 return *weakmap; |
| 646 } |
| 647 |
| 648 |
| 649 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { |
| 650 NoHandleAllocation ha; |
| 651 ASSERT(args.length() == 2); |
| 652 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); |
| 653 // TODO(mstarzinger): Currently we cannot use JSProxy objects as keys |
| 654 // because they cannot be cast to JSObject to get an identity hash code. |
| 655 CONVERT_ARG_CHECKED(JSObject, key, 1); |
| 656 return weakmap->table()->Lookup(*key); |
| 657 } |
| 658 |
| 659 |
| 660 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { |
| 661 HandleScope scope(isolate); |
| 662 ASSERT(args.length() == 3); |
| 663 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); |
| 664 // TODO(mstarzinger): See Runtime_WeakMapGet above. |
| 665 CONVERT_ARG_CHECKED(JSObject, key, 1); |
| 666 Handle<Object> value(args[2]); |
| 667 Handle<ObjectHashTable> table(weakmap->table()); |
| 668 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
| 669 weakmap->set_table(*new_table); |
| 670 return *value; |
| 671 } |
| 672 |
| 673 |
| 638 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 674 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
| 639 NoHandleAllocation ha; | 675 NoHandleAllocation ha; |
| 640 ASSERT(args.length() == 1); | 676 ASSERT(args.length() == 1); |
| 641 Object* obj = args[0]; | 677 Object* obj = args[0]; |
| 642 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 678 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
| 643 return JSObject::cast(obj)->class_name(); | 679 return JSObject::cast(obj)->class_name(); |
| 644 } | 680 } |
| 645 | 681 |
| 646 | 682 |
| 647 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 683 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 1030 |
| 995 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { | 1031 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { |
| 996 ASSERT(args.length() == 1); | 1032 ASSERT(args.length() == 1); |
| 997 CONVERT_CHECKED(JSObject, obj, args[0]); | 1033 CONVERT_CHECKED(JSObject, obj, args[0]); |
| 998 if (obj->IsJSGlobalProxy()) { | 1034 if (obj->IsJSGlobalProxy()) { |
| 999 Object* proto = obj->GetPrototype(); | 1035 Object* proto = obj->GetPrototype(); |
| 1000 if (proto->IsNull()) return isolate->heap()->false_value(); | 1036 if (proto->IsNull()) return isolate->heap()->false_value(); |
| 1001 ASSERT(proto->IsJSGlobalObject()); | 1037 ASSERT(proto->IsJSGlobalObject()); |
| 1002 obj = JSObject::cast(proto); | 1038 obj = JSObject::cast(proto); |
| 1003 } | 1039 } |
| 1004 return obj->map()->is_extensible() ? isolate->heap()->true_value() | 1040 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
| 1005 : isolate->heap()->false_value(); | |
| 1006 } | 1041 } |
| 1007 | 1042 |
| 1008 | 1043 |
| 1009 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { | 1044 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { |
| 1010 HandleScope scope(isolate); | 1045 HandleScope scope(isolate); |
| 1011 ASSERT(args.length() == 3); | 1046 ASSERT(args.length() == 3); |
| 1012 CONVERT_ARG_CHECKED(JSRegExp, re, 0); | 1047 CONVERT_ARG_CHECKED(JSRegExp, re, 0); |
| 1013 CONVERT_ARG_CHECKED(String, pattern, 1); | 1048 CONVERT_ARG_CHECKED(String, pattern, 1); |
| 1014 CONVERT_ARG_CHECKED(String, flags, 2); | 1049 CONVERT_ARG_CHECKED(String, flags, 2); |
| 1015 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 1050 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 if (needs_access_checks) { | 1096 if (needs_access_checks) { |
| 1062 // Copy map so it won't interfere constructor's initial map. | 1097 // Copy map so it won't interfere constructor's initial map. |
| 1063 Object* new_map; | 1098 Object* new_map; |
| 1064 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); | 1099 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); |
| 1065 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1100 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
| 1066 } | 1101 } |
| 1067 | 1102 |
| 1068 Map::cast(new_map)->set_is_access_check_needed(false); | 1103 Map::cast(new_map)->set_is_access_check_needed(false); |
| 1069 object->set_map(Map::cast(new_map)); | 1104 object->set_map(Map::cast(new_map)); |
| 1070 } | 1105 } |
| 1071 return needs_access_checks ? isolate->heap()->true_value() | 1106 return isolate->heap()->ToBoolean(needs_access_checks); |
| 1072 : isolate->heap()->false_value(); | |
| 1073 } | 1107 } |
| 1074 | 1108 |
| 1075 | 1109 |
| 1076 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { | 1110 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { |
| 1077 ASSERT(args.length() == 1); | 1111 ASSERT(args.length() == 1); |
| 1078 CONVERT_CHECKED(HeapObject, object, args[0]); | 1112 CONVERT_CHECKED(HeapObject, object, args[0]); |
| 1079 Map* old_map = object->map(); | 1113 Map* old_map = object->map(); |
| 1080 if (!old_map->is_access_check_needed()) { | 1114 if (!old_map->is_access_check_needed()) { |
| 1081 // Copy map so it won't interfere constructor's initial map. | 1115 // Copy map so it won't interfere constructor's initial map. |
| 1082 Object* new_map; | 1116 Object* new_map; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1199 } |
| 1166 // Fall-through and introduce the absent property by using | 1200 // Fall-through and introduce the absent property by using |
| 1167 // SetProperty. | 1201 // SetProperty. |
| 1168 } else { | 1202 } else { |
| 1169 // For const properties, we treat a callback with this name | 1203 // For const properties, we treat a callback with this name |
| 1170 // even in the prototype as a conflicting declaration. | 1204 // even in the prototype as a conflicting declaration. |
| 1171 if (is_const_property && (lookup.type() == CALLBACKS)) { | 1205 if (is_const_property && (lookup.type() == CALLBACKS)) { |
| 1172 return ThrowRedeclarationError(isolate, "const", name); | 1206 return ThrowRedeclarationError(isolate, "const", name); |
| 1173 } | 1207 } |
| 1174 // Otherwise, we check for locally conflicting declarations. | 1208 // Otherwise, we check for locally conflicting declarations. |
| 1175 if (is_local && is_const_property) { | 1209 if (is_local && (is_read_only || is_const_property)) { |
| 1176 const char* type = (is_read_only) ? "const" : "var"; | 1210 const char* type = (is_read_only) ? "const" : "var"; |
| 1177 return ThrowRedeclarationError(isolate, type, name); | 1211 return ThrowRedeclarationError(isolate, type, name); |
| 1178 } | 1212 } |
| 1179 // The property already exists without conflicting: Go to | 1213 // The property already exists without conflicting: Go to |
| 1180 // the next declaration. | 1214 // the next declaration. |
| 1181 continue; | 1215 continue; |
| 1182 } | 1216 } |
| 1183 } | 1217 } |
| 1184 } else { | 1218 } else { |
| 1185 // Copy the function and update its context. Use it as value. | 1219 // Copy the function and update its context. Use it as value. |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 if (type == INTERCEPTOR) { | 1433 if (type == INTERCEPTOR) { |
| 1400 HandleScope handle_scope(isolate); | 1434 HandleScope handle_scope(isolate); |
| 1401 Handle<JSObject> holder(real_holder); | 1435 Handle<JSObject> holder(real_holder); |
| 1402 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); | 1436 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); |
| 1403 real_holder = *holder; | 1437 real_holder = *holder; |
| 1404 if (intercepted == ABSENT) { | 1438 if (intercepted == ABSENT) { |
| 1405 // The interceptor claims the property isn't there. We need to | 1439 // The interceptor claims the property isn't there. We need to |
| 1406 // make sure to introduce it. | 1440 // make sure to introduce it. |
| 1407 found = false; | 1441 found = false; |
| 1408 } else if ((intercepted & READ_ONLY) != 0) { | 1442 } else if ((intercepted & READ_ONLY) != 0) { |
| 1409 // The property is present, but read-only, so we ignore the | 1443 // The property is present, but read-only. Since we're trying to |
| 1410 // redeclaration. However if we found readonly property | 1444 // overwrite it with a variable declaration we must throw a |
| 1445 // re-declaration error. However if we found readonly property |
| 1411 // on one of hidden prototypes, just shadow it. | 1446 // on one of hidden prototypes, just shadow it. |
| 1412 if (real_holder != isolate->context()->global()) break; | 1447 if (real_holder != isolate->context()->global()) break; |
| 1413 return isolate->heap()->undefined_value(); | 1448 return ThrowRedeclarationError(isolate, "const", name); |
| 1414 } | 1449 } |
| 1415 } | 1450 } |
| 1416 | 1451 |
| 1417 if (found && !assign) { | 1452 if (found && !assign) { |
| 1418 // The global property is there and we're not assigning any value | 1453 // The global property is there and we're not assigning any value |
| 1419 // to it. Just return. | 1454 // to it. Just return. |
| 1420 return isolate->heap()->undefined_value(); | 1455 return isolate->heap()->undefined_value(); |
| 1421 } | 1456 } |
| 1422 | 1457 |
| 1423 // Assign the value (or undefined) to the property. | 1458 // Assign the value (or undefined) to the property. |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 NoHandleAllocation ha; | 1907 NoHandleAllocation ha; |
| 1873 ASSERT(args.length() == 2); | 1908 ASSERT(args.length() == 2); |
| 1874 | 1909 |
| 1875 CONVERT_CHECKED(JSFunction, f, args[0]); | 1910 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1876 CONVERT_CHECKED(String, name, args[1]); | 1911 CONVERT_CHECKED(String, name, args[1]); |
| 1877 f->shared()->set_name(name); | 1912 f->shared()->set_name(name); |
| 1878 return isolate->heap()->undefined_value(); | 1913 return isolate->heap()->undefined_value(); |
| 1879 } | 1914 } |
| 1880 | 1915 |
| 1881 | 1916 |
| 1917 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 1918 NoHandleAllocation ha; |
| 1919 ASSERT(args.length() == 1); |
| 1920 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1921 return isolate->heap()->ToBoolean( |
| 1922 f->shared()->name_should_print_as_anonymous()); |
| 1923 } |
| 1924 |
| 1925 |
| 1926 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
| 1927 NoHandleAllocation ha; |
| 1928 ASSERT(args.length() == 1); |
| 1929 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1930 f->shared()->set_name_should_print_as_anonymous(true); |
| 1931 return isolate->heap()->undefined_value(); |
| 1932 } |
| 1933 |
| 1934 |
| 1882 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetBound) { | 1935 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetBound) { |
| 1883 HandleScope scope(isolate); | 1936 HandleScope scope(isolate); |
| 1884 ASSERT(args.length() == 1); | 1937 ASSERT(args.length() == 1); |
| 1885 | 1938 |
| 1886 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1939 CONVERT_CHECKED(JSFunction, fun, args[0]); |
| 1887 fun->shared()->set_bound(true); | 1940 fun->shared()->set_bound(true); |
| 1888 return isolate->heap()->undefined_value(); | 1941 return isolate->heap()->undefined_value(); |
| 1889 } | 1942 } |
| 1890 | 1943 |
| 1891 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 1944 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 NoHandleAllocation ha; | 2012 NoHandleAllocation ha; |
| 1960 ASSERT(args.length() == 2); | 2013 ASSERT(args.length() == 2); |
| 1961 | 2014 |
| 1962 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2015 CONVERT_CHECKED(JSFunction, fun, args[0]); |
| 1963 CONVERT_CHECKED(Smi, length, args[1]); | 2016 CONVERT_CHECKED(Smi, length, args[1]); |
| 1964 fun->shared()->set_length(length->value()); | 2017 fun->shared()->set_length(length->value()); |
| 1965 return length; | 2018 return length; |
| 1966 } | 2019 } |
| 1967 | 2020 |
| 1968 | 2021 |
| 2022 // Creates a local, readonly, property called length with the correct |
| 2023 // length (when read by the user). This effectively overwrites the |
| 2024 // interceptor used to normally provide the length. |
| 2025 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionSetLength) { |
| 2026 NoHandleAllocation ha; |
| 2027 ASSERT(args.length() == 2); |
| 2028 CONVERT_CHECKED(JSFunction, fun, args[0]); |
| 2029 CONVERT_CHECKED(Smi, length, args[1]); |
| 2030 MaybeObject* maybe_name = |
| 2031 isolate->heap()->AllocateStringFromAscii(CStrVector("length")); |
| 2032 String* name; |
| 2033 if (!maybe_name->To(&name)) return maybe_name; |
| 2034 PropertyAttributes attr = |
| 2035 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); |
| 2036 return fun->AddProperty(name, length, attr, kNonStrictMode); |
| 2037 } |
| 2038 |
| 2039 |
| 1969 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 2040 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { |
| 1970 NoHandleAllocation ha; | 2041 NoHandleAllocation ha; |
| 1971 ASSERT(args.length() == 2); | 2042 ASSERT(args.length() == 2); |
| 1972 | 2043 |
| 1973 CONVERT_CHECKED(JSFunction, fun, args[0]); | 2044 CONVERT_CHECKED(JSFunction, fun, args[0]); |
| 1974 ASSERT(fun->should_have_prototype()); | 2045 ASSERT(fun->should_have_prototype()); |
| 1975 Object* obj; | 2046 Object* obj; |
| 1976 { MaybeObject* maybe_obj = | 2047 { MaybeObject* maybe_obj = |
| 1977 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 2048 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
| 1978 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2049 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 } | 2105 } |
| 2035 return function; | 2106 return function; |
| 2036 } | 2107 } |
| 2037 | 2108 |
| 2038 | 2109 |
| 2039 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2110 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
| 2040 NoHandleAllocation ha; | 2111 NoHandleAllocation ha; |
| 2041 ASSERT(args.length() == 1); | 2112 ASSERT(args.length() == 1); |
| 2042 | 2113 |
| 2043 CONVERT_CHECKED(JSFunction, f, args[0]); | 2114 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 2044 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() | 2115 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
| 2045 : isolate->heap()->false_value(); | |
| 2046 } | 2116 } |
| 2047 | 2117 |
| 2048 | 2118 |
| 2049 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 2119 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
| 2050 NoHandleAllocation ha; | 2120 NoHandleAllocation ha; |
| 2051 ASSERT(args.length() == 1); | 2121 ASSERT(args.length() == 1); |
| 2052 | 2122 |
| 2053 CONVERT_CHECKED(JSFunction, f, args[0]); | 2123 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 2054 return f->IsBuiltin() ? isolate->heap()->true_value() : | 2124 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
| 2055 isolate->heap()->false_value(); | |
| 2056 } | 2125 } |
| 2057 | 2126 |
| 2058 | 2127 |
| 2059 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 2128 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
| 2060 HandleScope scope(isolate); | 2129 HandleScope scope(isolate); |
| 2061 ASSERT(args.length() == 2); | 2130 ASSERT(args.length() == 2); |
| 2062 | 2131 |
| 2063 CONVERT_ARG_CHECKED(JSFunction, target, 0); | 2132 CONVERT_ARG_CHECKED(JSFunction, target, 0); |
| 2064 Handle<Object> code = args.at<Object>(1); | 2133 Handle<Object> code = args.at<Object>(1); |
| 2065 | 2134 |
| (...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4524 } | 4593 } |
| 4525 } | 4594 } |
| 4526 | 4595 |
| 4527 // Allocate an array with storage for all the property names. | 4596 // Allocate an array with storage for all the property names. |
| 4528 Handle<FixedArray> names = | 4597 Handle<FixedArray> names = |
| 4529 isolate->factory()->NewFixedArray(total_property_count); | 4598 isolate->factory()->NewFixedArray(total_property_count); |
| 4530 | 4599 |
| 4531 // Get the property names. | 4600 // Get the property names. |
| 4532 jsproto = obj; | 4601 jsproto = obj; |
| 4533 int proto_with_hidden_properties = 0; | 4602 int proto_with_hidden_properties = 0; |
| 4603 int next_copy_index = 0; |
| 4534 for (int i = 0; i < length; i++) { | 4604 for (int i = 0; i < length; i++) { |
| 4535 jsproto->GetLocalPropertyNames(*names, | 4605 jsproto->GetLocalPropertyNames(*names, next_copy_index); |
| 4536 i == 0 ? 0 : local_property_count[i - 1]); | 4606 next_copy_index += local_property_count[i]; |
| 4537 if (jsproto->HasHiddenProperties()) { | 4607 if (jsproto->HasHiddenProperties()) { |
| 4538 proto_with_hidden_properties++; | 4608 proto_with_hidden_properties++; |
| 4539 } | 4609 } |
| 4540 if (i < length - 1) { | 4610 if (i < length - 1) { |
| 4541 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 4611 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 4542 } | 4612 } |
| 4543 } | 4613 } |
| 4544 | 4614 |
| 4545 // Filter out name of hidden propeties object. | 4615 // Filter out name of hidden propeties object. |
| 4546 if (proto_with_hidden_properties > 0) { | 4616 if (proto_with_hidden_properties > 0) { |
| (...skipping 4648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9195 ArrayConcatVisitor* visitor) { | 9265 ArrayConcatVisitor* visitor) { |
| 9196 Handle<ExternalArrayClass> array( | 9266 Handle<ExternalArrayClass> array( |
| 9197 ExternalArrayClass::cast(receiver->elements())); | 9267 ExternalArrayClass::cast(receiver->elements())); |
| 9198 uint32_t len = static_cast<uint32_t>(array->length()); | 9268 uint32_t len = static_cast<uint32_t>(array->length()); |
| 9199 | 9269 |
| 9200 ASSERT(visitor != NULL); | 9270 ASSERT(visitor != NULL); |
| 9201 if (elements_are_ints) { | 9271 if (elements_are_ints) { |
| 9202 if (elements_are_guaranteed_smis) { | 9272 if (elements_are_guaranteed_smis) { |
| 9203 for (uint32_t j = 0; j < len; j++) { | 9273 for (uint32_t j = 0; j < len; j++) { |
| 9204 HandleScope loop_scope; | 9274 HandleScope loop_scope; |
| 9205 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get(j)))); | 9275 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j)))); |
| 9206 visitor->visit(j, e); | 9276 visitor->visit(j, e); |
| 9207 } | 9277 } |
| 9208 } else { | 9278 } else { |
| 9209 for (uint32_t j = 0; j < len; j++) { | 9279 for (uint32_t j = 0; j < len; j++) { |
| 9210 HandleScope loop_scope; | 9280 HandleScope loop_scope; |
| 9211 int64_t val = static_cast<int64_t>(array->get(j)); | 9281 int64_t val = static_cast<int64_t>(array->get_scalar(j)); |
| 9212 if (Smi::IsValid(static_cast<intptr_t>(val))) { | 9282 if (Smi::IsValid(static_cast<intptr_t>(val))) { |
| 9213 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); | 9283 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); |
| 9214 visitor->visit(j, e); | 9284 visitor->visit(j, e); |
| 9215 } else { | 9285 } else { |
| 9216 Handle<Object> e = | 9286 Handle<Object> e = |
| 9217 isolate->factory()->NewNumber(static_cast<ElementType>(val)); | 9287 isolate->factory()->NewNumber(static_cast<ElementType>(val)); |
| 9218 visitor->visit(j, e); | 9288 visitor->visit(j, e); |
| 9219 } | 9289 } |
| 9220 } | 9290 } |
| 9221 } | 9291 } |
| 9222 } else { | 9292 } else { |
| 9223 for (uint32_t j = 0; j < len; j++) { | 9293 for (uint32_t j = 0; j < len; j++) { |
| 9224 HandleScope loop_scope(isolate); | 9294 HandleScope loop_scope(isolate); |
| 9225 Handle<Object> e = isolate->factory()->NewNumber(array->get(j)); | 9295 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); |
| 9226 visitor->visit(j, e); | 9296 visitor->visit(j, e); |
| 9227 } | 9297 } |
| 9228 } | 9298 } |
| 9229 } | 9299 } |
| 9230 | 9300 |
| 9231 | 9301 |
| 9232 // Used for sorting indices in a List<uint32_t>. | 9302 // Used for sorting indices in a List<uint32_t>. |
| 9233 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { | 9303 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { |
| 9234 uint32_t a = *ap; | 9304 uint32_t a = *ap; |
| 9235 uint32_t b = *bp; | 9305 uint32_t b = *bp; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9401 do { | 9471 do { |
| 9402 j++; | 9472 j++; |
| 9403 } while (j < n && indices[j] == index); | 9473 } while (j < n && indices[j] == index); |
| 9404 } | 9474 } |
| 9405 break; | 9475 break; |
| 9406 } | 9476 } |
| 9407 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { | 9477 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { |
| 9408 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( | 9478 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( |
| 9409 receiver->elements())); | 9479 receiver->elements())); |
| 9410 for (uint32_t j = 0; j < length; j++) { | 9480 for (uint32_t j = 0; j < length; j++) { |
| 9411 Handle<Smi> e(Smi::FromInt(pixels->get(j))); | 9481 Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j))); |
| 9412 visitor->visit(j, e); | 9482 visitor->visit(j, e); |
| 9413 } | 9483 } |
| 9414 break; | 9484 break; |
| 9415 } | 9485 } |
| 9416 case JSObject::EXTERNAL_BYTE_ELEMENTS: { | 9486 case JSObject::EXTERNAL_BYTE_ELEMENTS: { |
| 9417 IterateExternalArrayElements<ExternalByteArray, int8_t>( | 9487 IterateExternalArrayElements<ExternalByteArray, int8_t>( |
| 9418 isolate, receiver, true, true, visitor); | 9488 isolate, receiver, true, true, visitor); |
| 9419 break; | 9489 break; |
| 9420 } | 9490 } |
| 9421 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 9491 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9919 | 9989 |
| 9920 // If the callback object is a fixed array then it contains JavaScript | 9990 // If the callback object is a fixed array then it contains JavaScript |
| 9921 // getter and/or setter. | 9991 // getter and/or setter. |
| 9922 bool hasJavaScriptAccessors = result_type == CALLBACKS && | 9992 bool hasJavaScriptAccessors = result_type == CALLBACKS && |
| 9923 result_callback_obj->IsFixedArray(); | 9993 result_callback_obj->IsFixedArray(); |
| 9924 Handle<FixedArray> details = | 9994 Handle<FixedArray> details = |
| 9925 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); | 9995 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); |
| 9926 details->set(0, *value); | 9996 details->set(0, *value); |
| 9927 details->set(1, property_details); | 9997 details->set(1, property_details); |
| 9928 if (hasJavaScriptAccessors) { | 9998 if (hasJavaScriptAccessors) { |
| 9929 details->set(2, | 9999 details->set(2, isolate->heap()->ToBoolean(caught_exception)); |
| 9930 caught_exception ? isolate->heap()->true_value() | |
| 9931 : isolate->heap()->false_value()); | |
| 9932 details->set(3, FixedArray::cast(*result_callback_obj)->get(0)); | 10000 details->set(3, FixedArray::cast(*result_callback_obj)->get(0)); |
| 9933 details->set(4, FixedArray::cast(*result_callback_obj)->get(1)); | 10001 details->set(4, FixedArray::cast(*result_callback_obj)->get(1)); |
| 9934 } | 10002 } |
| 9935 | 10003 |
| 9936 return *isolate->factory()->NewJSArrayWithElements(details); | 10004 return *isolate->factory()->NewJSArrayWithElements(details); |
| 9937 } | 10005 } |
| 9938 if (i < length - 1) { | 10006 if (i < length - 1) { |
| 9939 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10007 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 9940 } | 10008 } |
| 9941 } | 10009 } |
| (...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11377 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); | 11445 RETURN_IF_EMPTY_HANDLE(isolate, local_scope); |
| 11378 | 11446 |
| 11379 // Allocate a new context for the debug evaluation and set the extension | 11447 // Allocate a new context for the debug evaluation and set the extension |
| 11380 // object build. | 11448 // object build. |
| 11381 Handle<Context> context = | 11449 Handle<Context> context = |
| 11382 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, | 11450 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
| 11383 go_between); | 11451 go_between); |
| 11384 context->set_extension(*local_scope); | 11452 context->set_extension(*local_scope); |
| 11385 // Copy any with contexts present and chain them in front of this context. | 11453 // Copy any with contexts present and chain them in front of this context. |
| 11386 Handle<Context> frame_context(Context::cast(frame->context())); | 11454 Handle<Context> frame_context(Context::cast(frame->context())); |
| 11387 Handle<Context> function_context(frame_context->declaration_context()); | 11455 Handle<Context> function_context; |
| 11456 // Get the function's context if it has one. |
| 11457 if (scope_info->HasHeapAllocatedLocals()) { |
| 11458 function_context = Handle<Context>(frame_context->declaration_context()); |
| 11459 } |
| 11388 context = CopyWithContextChain(isolate, go_between, frame_context, context); | 11460 context = CopyWithContextChain(isolate, go_between, frame_context, context); |
| 11389 | 11461 |
| 11390 if (additional_context->IsJSObject()) { | 11462 if (additional_context->IsJSObject()) { |
| 11391 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); | 11463 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); |
| 11392 context = | 11464 context = |
| 11393 isolate->factory()->NewWithContext(go_between, context, extension); | 11465 isolate->factory()->NewWithContext(go_between, context, extension); |
| 11394 } | 11466 } |
| 11395 | 11467 |
| 11396 // Wrap the evaluation statement in a new function compiled in the newly | 11468 // Wrap the evaluation statement in a new function compiled in the newly |
| 11397 // created context. The function has one parameter which has to be called | 11469 // created context. The function has one parameter which has to be called |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12143 return isolate->heap()->undefined_value(); | 12215 return isolate->heap()->undefined_value(); |
| 12144 #endif | 12216 #endif |
| 12145 } | 12217 } |
| 12146 | 12218 |
| 12147 | 12219 |
| 12148 // Deletes the specified live object list. | 12220 // Deletes the specified live object list. |
| 12149 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { | 12221 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { |
| 12150 #ifdef LIVE_OBJECT_LIST | 12222 #ifdef LIVE_OBJECT_LIST |
| 12151 CONVERT_SMI_ARG_CHECKED(id, 0); | 12223 CONVERT_SMI_ARG_CHECKED(id, 0); |
| 12152 bool success = LiveObjectList::Delete(id); | 12224 bool success = LiveObjectList::Delete(id); |
| 12153 return success ? isolate->heap()->true_value() : | 12225 return isolate->heap()->ToBoolean(success); |
| 12154 isolate->heap()->false_value(); | |
| 12155 #else | 12226 #else |
| 12156 return isolate->heap()->undefined_value(); | 12227 return isolate->heap()->undefined_value(); |
| 12157 #endif | 12228 #endif |
| 12158 } | 12229 } |
| 12159 | 12230 |
| 12160 | 12231 |
| 12161 // Generates the response to a debugger request for a dump of the objects | 12232 // Generates the response to a debugger request for a dump of the objects |
| 12162 // contained in the difference between the captured live object lists | 12233 // contained in the difference between the captured live object lists |
| 12163 // specified by id1 and id2. | 12234 // specified by id1 and id2. |
| 12164 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be | 12235 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12812 } else { | 12883 } else { |
| 12813 // Handle last resort GC and make sure to allow future allocations | 12884 // Handle last resort GC and make sure to allow future allocations |
| 12814 // to grow the heap without causing GCs (if possible). | 12885 // to grow the heap without causing GCs (if possible). |
| 12815 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12886 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 12816 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 12887 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 12817 } | 12888 } |
| 12818 } | 12889 } |
| 12819 | 12890 |
| 12820 | 12891 |
| 12821 } } // namespace v8::internal | 12892 } } // namespace v8::internal |
| OLD | NEW |