| 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 return symbol; | 630 return symbol; |
| 631 } | 631 } |
| 632 | 632 |
| 633 | 633 |
| 634 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { | 634 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { |
| 635 HandleScope scope(isolate); | 635 HandleScope scope(isolate); |
| 636 ASSERT(args.length() == 1); | 636 ASSERT(args.length() == 1); |
| 637 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 637 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 638 Handle<JSObject> registry = isolate->GetSymbolRegistry(); | 638 Handle<JSObject> registry = isolate->GetSymbolRegistry(); |
| 639 Handle<String> part = isolate->factory()->private_intern_string(); | 639 Handle<String> part = isolate->factory()->private_intern_string(); |
| 640 Handle<JSObject> privates = | 640 Handle<Object> privates; |
| 641 Handle<JSObject>::cast(Object::GetPropertyOrElement(registry, part)); | 641 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 642 Handle<Object> symbol = Object::GetPropertyOrElement(privates, name); | 642 isolate, privates, Object::GetPropertyOrElement(registry, part)); |
| 643 Handle<Object> symbol; |
| 644 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 645 isolate, symbol, Object::GetPropertyOrElement(privates, name)); |
| 643 if (!symbol->IsSymbol()) { | 646 if (!symbol->IsSymbol()) { |
| 644 ASSERT(symbol->IsUndefined()); | 647 ASSERT(symbol->IsUndefined()); |
| 645 symbol = isolate->factory()->NewPrivateSymbol(); | 648 symbol = isolate->factory()->NewPrivateSymbol(); |
| 646 Handle<Symbol>::cast(symbol)->set_name(*name); | 649 Handle<Symbol>::cast(symbol)->set_name(*name); |
| 647 JSObject::SetProperty(privates, name, symbol, NONE, STRICT).Assert(); | 650 JSObject::SetProperty(Handle<JSObject>::cast(privates), |
| 651 name, symbol, NONE, STRICT).Assert(); |
| 648 } | 652 } |
| 649 return *symbol; | 653 return *symbol; |
| 650 } | 654 } |
| 651 | 655 |
| 652 | 656 |
| 653 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) { | 657 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) { |
| 654 ASSERT(args.length() == 1); | 658 ASSERT(args.length() == 1); |
| 655 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 659 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
| 656 return symbol->ToObject(isolate); | 660 return symbol->ToObject(isolate); |
| 657 } | 661 } |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 VALUE_INDEX, | 1904 VALUE_INDEX, |
| 1901 GETTER_INDEX, | 1905 GETTER_INDEX, |
| 1902 SETTER_INDEX, | 1906 SETTER_INDEX, |
| 1903 WRITABLE_INDEX, | 1907 WRITABLE_INDEX, |
| 1904 ENUMERABLE_INDEX, | 1908 ENUMERABLE_INDEX, |
| 1905 CONFIGURABLE_INDEX, | 1909 CONFIGURABLE_INDEX, |
| 1906 DESCRIPTOR_SIZE | 1910 DESCRIPTOR_SIZE |
| 1907 }; | 1911 }; |
| 1908 | 1912 |
| 1909 | 1913 |
| 1910 static Handle<Object> GetOwnProperty(Isolate* isolate, | 1914 MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty( |
| 1911 Handle<JSObject> obj, | 1915 Isolate* isolate, |
| 1912 Handle<Name> name) { | 1916 Handle<JSObject> obj, |
| 1917 Handle<Name> name) { |
| 1913 Heap* heap = isolate->heap(); | 1918 Heap* heap = isolate->heap(); |
| 1914 Factory* factory = isolate->factory(); | 1919 Factory* factory = isolate->factory(); |
| 1915 // Due to some WebKit tests, we want to make sure that we do not log | 1920 // Due to some WebKit tests, we want to make sure that we do not log |
| 1916 // more than one access failure here. | 1921 // more than one access failure here. |
| 1917 AccessCheckResult access_check_result = | 1922 AccessCheckResult access_check_result = |
| 1918 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); | 1923 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); |
| 1919 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 1924 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1920 switch (access_check_result) { | 1925 switch (access_check_result) { |
| 1921 case ACCESS_FORBIDDEN: return factory->false_value(); | 1926 case ACCESS_FORBIDDEN: return factory->false_value(); |
| 1922 case ACCESS_ALLOWED: break; | 1927 case ACCESS_ALLOWED: break; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1933 bool has_accessors = | 1938 bool has_accessors = |
| 1934 JSObject::GetLocalPropertyAccessorPair(obj, name).ToHandle(&accessors); | 1939 JSObject::GetLocalPropertyAccessorPair(obj, name).ToHandle(&accessors); |
| 1935 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 1940 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
| 1936 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 1941 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
| 1937 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 1942 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
| 1938 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(has_accessors)); | 1943 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(has_accessors)); |
| 1939 | 1944 |
| 1940 if (!has_accessors) { | 1945 if (!has_accessors) { |
| 1941 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 1946 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
| 1942 // Runtime::GetObjectProperty does access check. | 1947 // Runtime::GetObjectProperty does access check. |
| 1943 Handle<Object> value = Runtime::GetObjectProperty(isolate, obj, name); | 1948 Handle<Object> value; |
| 1944 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<Object>::null()); | 1949 ASSIGN_RETURN_ON_EXCEPTION( |
| 1950 isolate, value, Runtime::GetObjectProperty(isolate, obj, name), |
| 1951 Object); |
| 1945 elms->set(VALUE_INDEX, *value); | 1952 elms->set(VALUE_INDEX, *value); |
| 1946 } else { | 1953 } else { |
| 1947 // Access checks are performed for both accessors separately. | 1954 // Access checks are performed for both accessors separately. |
| 1948 // When they fail, the respective field is not set in the descriptor. | 1955 // When they fail, the respective field is not set in the descriptor. |
| 1949 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); | 1956 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); |
| 1950 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); | 1957 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); |
| 1951 | 1958 |
| 1952 if (!getter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_GET)) { | 1959 if (!getter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_GET)) { |
| 1953 ASSERT(!isolate->has_scheduled_exception()); | 1960 ASSERT(!isolate->has_scheduled_exception()); |
| 1954 elms->set(GETTER_INDEX, *getter); | 1961 elms->set(GETTER_INDEX, *getter); |
| 1955 } else { | 1962 } else { |
| 1956 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 1963 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1957 } | 1964 } |
| 1958 | 1965 |
| 1959 if (!setter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_SET)) { | 1966 if (!setter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_SET)) { |
| 1960 ASSERT(!isolate->has_scheduled_exception()); | 1967 ASSERT(!isolate->has_scheduled_exception()); |
| 1961 elms->set(SETTER_INDEX, *setter); | 1968 elms->set(SETTER_INDEX, *setter); |
| 1962 } else { | 1969 } else { |
| 1963 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 1970 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1964 } | 1971 } |
| 1965 } | 1972 } |
| 1966 | 1973 |
| 1967 return isolate->factory()->NewJSArrayWithElements(elms); | 1974 return isolate->factory()->NewJSArrayWithElements(elms); |
| 1968 } | 1975 } |
| 1969 | 1976 |
| 1970 | 1977 |
| 1971 // Returns an array with the property description: | 1978 // Returns an array with the property description: |
| 1972 // if args[1] is not a property on args[0] | 1979 // if args[1] is not a property on args[0] |
| 1973 // returns undefined | 1980 // returns undefined |
| 1974 // if args[1] is a data property on args[0] | 1981 // if args[1] is a data property on args[0] |
| 1975 // [false, value, Writeable, Enumerable, Configurable] | 1982 // [false, value, Writeable, Enumerable, Configurable] |
| 1976 // if args[1] is an accessor on args[0] | 1983 // if args[1] is an accessor on args[0] |
| 1977 // [true, GetFunction, SetFunction, Enumerable, Configurable] | 1984 // [true, GetFunction, SetFunction, Enumerable, Configurable] |
| 1978 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { | 1985 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { |
| 1979 HandleScope scope(isolate); | 1986 HandleScope scope(isolate); |
| 1980 ASSERT(args.length() == 2); | 1987 ASSERT(args.length() == 2); |
| 1981 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1988 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 1982 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 1989 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 1983 Handle<Object> result = GetOwnProperty(isolate, obj, name); | 1990 Handle<Object> result; |
| 1984 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1991 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1992 isolate, result, GetOwnProperty(isolate, obj, name)); |
| 1985 return *result; | 1993 return *result; |
| 1986 } | 1994 } |
| 1987 | 1995 |
| 1988 | 1996 |
| 1989 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { | 1997 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { |
| 1990 HandleScope scope(isolate); | 1998 HandleScope scope(isolate); |
| 1991 ASSERT(args.length() == 1); | 1999 ASSERT(args.length() == 1); |
| 1992 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 2000 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 1993 Handle<Object> result = JSObject::PreventExtensions(obj); | 2001 Handle<Object> result = JSObject::PreventExtensions(obj); |
| 1994 RETURN_IF_EMPTY_HANDLE(isolate, result); | 2002 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| (...skipping 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4873 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { | 4881 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { |
| 4874 if (index < static_cast<uint32_t>(string->length())) { | 4882 if (index < static_cast<uint32_t>(string->length())) { |
| 4875 Factory* factory = string->GetIsolate()->factory(); | 4883 Factory* factory = string->GetIsolate()->factory(); |
| 4876 return factory->LookupSingleCharacterStringFromCode( | 4884 return factory->LookupSingleCharacterStringFromCode( |
| 4877 String::Flatten(string)->Get(index)); | 4885 String::Flatten(string)->Get(index)); |
| 4878 } | 4886 } |
| 4879 return Execution::CharAt(string, index); | 4887 return Execution::CharAt(string, index); |
| 4880 } | 4888 } |
| 4881 | 4889 |
| 4882 | 4890 |
| 4883 Handle<Object> Runtime::GetElementOrCharAt(Isolate* isolate, | 4891 MaybeHandle<Object> Runtime::GetElementOrCharAt(Isolate* isolate, |
| 4884 Handle<Object> object, | 4892 Handle<Object> object, |
| 4885 uint32_t index) { | 4893 uint32_t index) { |
| 4886 // Handle [] indexing on Strings | 4894 // Handle [] indexing on Strings |
| 4887 if (object->IsString()) { | 4895 if (object->IsString()) { |
| 4888 Handle<Object> result = GetCharAt(Handle<String>::cast(object), index); | 4896 Handle<Object> result = GetCharAt(Handle<String>::cast(object), index); |
| 4889 if (!result->IsUndefined()) return result; | 4897 if (!result->IsUndefined()) return result; |
| 4890 } | 4898 } |
| 4891 | 4899 |
| 4892 // Handle [] indexing on String objects | 4900 // Handle [] indexing on String objects |
| 4893 if (object->IsStringObjectWithCharacterAt(index)) { | 4901 if (object->IsStringObjectWithCharacterAt(index)) { |
| 4894 Handle<JSValue> js_value = Handle<JSValue>::cast(object); | 4902 Handle<JSValue> js_value = Handle<JSValue>::cast(object); |
| 4895 Handle<Object> result = | 4903 Handle<Object> result = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4930 } | 4938 } |
| 4931 | 4939 |
| 4932 // Convert the key to a name - possibly by calling back into JavaScript. | 4940 // Convert the key to a name - possibly by calling back into JavaScript. |
| 4933 Handle<Name> name = ToName(isolate, key); | 4941 Handle<Name> name = ToName(isolate, key); |
| 4934 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, MaybeHandle<Object>()); | 4942 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, MaybeHandle<Object>()); |
| 4935 | 4943 |
| 4936 return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name)); | 4944 return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name)); |
| 4937 } | 4945 } |
| 4938 | 4946 |
| 4939 | 4947 |
| 4940 Handle<Object> Runtime::GetObjectProperty(Isolate* isolate, | 4948 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, |
| 4941 Handle<Object> object, | 4949 Handle<Object> object, |
| 4942 Handle<Object> key) { | 4950 Handle<Object> key) { |
| 4943 if (object->IsUndefined() || object->IsNull()) { | 4951 if (object->IsUndefined() || object->IsNull()) { |
| 4944 Handle<Object> args[2] = { key, object }; | 4952 Handle<Object> args[2] = { key, object }; |
| 4945 isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load", | 4953 isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load", |
| 4946 HandleVector(args, 2))); | 4954 HandleVector(args, 2))); |
| 4947 return Handle<Object>(); | 4955 return Handle<Object>(); |
| 4948 } | 4956 } |
| 4949 | 4957 |
| 4950 // Check if the given key is an array index. | 4958 // Check if the given key is an array index. |
| 4951 uint32_t index; | 4959 uint32_t index; |
| 4952 if (key->ToArrayIndex(&index)) { | 4960 if (key->ToArrayIndex(&index)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4966 } | 4974 } |
| 4967 } | 4975 } |
| 4968 | 4976 |
| 4969 | 4977 |
| 4970 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 4978 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
| 4971 HandleScope scope(isolate); | 4979 HandleScope scope(isolate); |
| 4972 ASSERT(args.length() == 2); | 4980 ASSERT(args.length() == 2); |
| 4973 | 4981 |
| 4974 Handle<Object> object = args.at<Object>(0); | 4982 Handle<Object> object = args.at<Object>(0); |
| 4975 Handle<Object> key = args.at<Object>(1); | 4983 Handle<Object> key = args.at<Object>(1); |
| 4976 Handle<Object> result = Runtime::GetObjectProperty(isolate, object, key); | 4984 Handle<Object> result; |
| 4977 RETURN_IF_EMPTY_HANDLE(isolate, result); | 4985 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 4986 isolate, result, |
| 4987 Runtime::GetObjectProperty(isolate, object, key)); |
| 4978 return *result; | 4988 return *result; |
| 4979 } | 4989 } |
| 4980 | 4990 |
| 4981 | 4991 |
| 4982 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 4992 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
| 4983 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 4993 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
| 4984 SealHandleScope shs(isolate); | 4994 SealHandleScope shs(isolate); |
| 4985 ASSERT(args.length() == 2); | 4995 ASSERT(args.length() == 2); |
| 4986 | 4996 |
| 4987 // Fast cases for getting named properties of the receiver JSObject | 4997 // Fast cases for getting named properties of the receiver JSObject |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5069 Handle<String> str = args.at<String>(0); | 5079 Handle<String> str = args.at<String>(0); |
| 5070 int index = args.smi_at(1); | 5080 int index = args.smi_at(1); |
| 5071 if (index >= 0 && index < str->length()) { | 5081 if (index >= 0 && index < str->length()) { |
| 5072 Handle<Object> result = GetCharAt(str, index); | 5082 Handle<Object> result = GetCharAt(str, index); |
| 5073 return *result; | 5083 return *result; |
| 5074 } | 5084 } |
| 5075 } | 5085 } |
| 5076 | 5086 |
| 5077 // Fall back to GetObjectProperty. | 5087 // Fall back to GetObjectProperty. |
| 5078 HandleScope scope(isolate); | 5088 HandleScope scope(isolate); |
| 5079 Handle<Object> result = Runtime::GetObjectProperty( | 5089 Handle<Object> result; |
| 5080 isolate, args.at<Object>(0), args.at<Object>(1)); | 5090 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5081 RETURN_IF_EMPTY_HANDLE(isolate, result); | 5091 isolate, result, |
| 5092 Runtime::GetObjectProperty( |
| 5093 isolate, args.at<Object>(0), args.at<Object>(1))); |
| 5082 return *result; | 5094 return *result; |
| 5083 } | 5095 } |
| 5084 | 5096 |
| 5085 | 5097 |
| 5086 static bool IsValidAccessor(Handle<Object> obj) { | 5098 static bool IsValidAccessor(Handle<Object> obj) { |
| 5087 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); | 5099 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); |
| 5088 } | 5100 } |
| 5089 | 5101 |
| 5090 | 5102 |
| 5091 // Implements part of 8.12.9 DefineOwnProperty. | 5103 // Implements part of 8.12.9 DefineOwnProperty. |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5738 } | 5750 } |
| 5739 ASSERT(!isolate->has_scheduled_exception()); | 5751 ASSERT(!isolate->has_scheduled_exception()); |
| 5740 return isolate->heap()->true_value(); | 5752 return isolate->heap()->true_value(); |
| 5741 } | 5753 } |
| 5742 | 5754 |
| 5743 | 5755 |
| 5744 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { | 5756 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { |
| 5745 HandleScope scope(isolate); | 5757 HandleScope scope(isolate); |
| 5746 ASSERT(args.length() == 1); | 5758 ASSERT(args.length() == 1); |
| 5747 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5759 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 5748 bool threw = false; | 5760 Handle<JSArray> result; |
| 5749 Handle<JSArray> result = GetKeysFor(object, &threw); | 5761 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, GetKeysFor(object)); |
| 5750 if (threw) return Failure::Exception(); | |
| 5751 return *result; | 5762 return *result; |
| 5752 } | 5763 } |
| 5753 | 5764 |
| 5754 | 5765 |
| 5755 // Returns either a FixedArray as Runtime_GetPropertyNames, | 5766 // Returns either a FixedArray as Runtime_GetPropertyNames, |
| 5756 // or, if the given object has an enum cache that contains | 5767 // or, if the given object has an enum cache that contains |
| 5757 // all enumerable properties of the object and its prototypes | 5768 // all enumerable properties of the object and its prototypes |
| 5758 // have none, the map of the object. This is used to speed up | 5769 // have none, the map of the object. This is used to speed up |
| 5759 // the check for deletions during a for-in. | 5770 // the check for deletions during a for-in. |
| 5760 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { | 5771 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { |
| 5761 SealHandleScope shs(isolate); | 5772 SealHandleScope shs(isolate); |
| 5762 ASSERT(args.length() == 1); | 5773 ASSERT(args.length() == 1); |
| 5763 | 5774 |
| 5764 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); | 5775 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); |
| 5765 | 5776 |
| 5766 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 5777 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
| 5767 | 5778 |
| 5768 HandleScope scope(isolate); | 5779 HandleScope scope(isolate); |
| 5769 Handle<JSReceiver> object(raw_object); | 5780 Handle<JSReceiver> object(raw_object); |
| 5770 bool threw = false; | 5781 Handle<FixedArray> content; |
| 5771 Handle<FixedArray> content = | 5782 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5772 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw); | 5783 isolate, content, GetKeysInFixedArrayFor(object, INCLUDE_PROTOS)); |
| 5773 if (threw) return Failure::Exception(); | |
| 5774 | 5784 |
| 5775 // Test again, since cache may have been built by preceding call. | 5785 // Test again, since cache may have been built by preceding call. |
| 5776 if (object->IsSimpleEnum()) return object->map(); | 5786 if (object->IsSimpleEnum()) return object->map(); |
| 5777 | 5787 |
| 5778 return *content; | 5788 return *content; |
| 5779 } | 5789 } |
| 5780 | 5790 |
| 5781 | 5791 |
| 5782 // Find the length of the prototype chain that is to to handled as one. If a | 5792 // Find the length of the prototype chain that is to to handled as one. If a |
| 5783 // prototype object is hidden it is to be viewed as part of the the object it | 5793 // prototype object is hidden it is to be viewed as part of the the object it |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5992 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 6002 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 5993 return *isolate->factory()->NewJSArray(0); | 6003 return *isolate->factory()->NewJSArray(0); |
| 5994 } | 6004 } |
| 5995 | 6005 |
| 5996 Handle<Object> proto(object->GetPrototype(), isolate); | 6006 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5997 // If proxy is detached we simply return an empty array. | 6007 // If proxy is detached we simply return an empty array. |
| 5998 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); | 6008 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); |
| 5999 object = Handle<JSObject>::cast(proto); | 6009 object = Handle<JSObject>::cast(proto); |
| 6000 } | 6010 } |
| 6001 | 6011 |
| 6002 bool threw = false; | 6012 Handle<FixedArray> contents; |
| 6003 Handle<FixedArray> contents = | 6013 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6004 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &threw); | 6014 isolate, contents, GetKeysInFixedArrayFor(object, LOCAL_ONLY)); |
| 6005 if (threw) return Failure::Exception(); | |
| 6006 | 6015 |
| 6007 // Some fast paths through GetKeysInFixedArrayFor reuse a cached | 6016 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
| 6008 // property array and since the result is mutable we have to create | 6017 // property array and since the result is mutable we have to create |
| 6009 // a fresh clone on each invocation. | 6018 // a fresh clone on each invocation. |
| 6010 int length = contents->length(); | 6019 int length = contents->length(); |
| 6011 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); | 6020 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); |
| 6012 for (int i = 0; i < length; i++) { | 6021 for (int i = 0; i < length; i++) { |
| 6013 Object* entry = contents->get(i); | 6022 Object* entry = contents->get(i); |
| 6014 if (entry->IsString()) { | 6023 if (entry->IsString()) { |
| 6015 copy->set(i, entry); | 6024 copy->set(i, entry); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6060 Execution::ToString(isolate, args.at<Object>(0), &exception); | 6069 Execution::ToString(isolate, args.at<Object>(0), &exception); |
| 6061 if (exception) return Failure::Exception(); | 6070 if (exception) return Failure::Exception(); |
| 6062 Handle<String> key = Handle<String>::cast(converted); | 6071 Handle<String> key = Handle<String>::cast(converted); |
| 6063 | 6072 |
| 6064 // Try to convert the string key into an array index. | 6073 // Try to convert the string key into an array index. |
| 6065 if (key->AsArrayIndex(&index)) { | 6074 if (key->AsArrayIndex(&index)) { |
| 6066 if (index < n) { | 6075 if (index < n) { |
| 6067 return frame->GetParameter(index); | 6076 return frame->GetParameter(index); |
| 6068 } else { | 6077 } else { |
| 6069 Handle<Object> initial_prototype(isolate->initial_object_prototype()); | 6078 Handle<Object> initial_prototype(isolate->initial_object_prototype()); |
| 6070 Handle<Object> result = | 6079 Handle<Object> result; |
| 6071 Object::GetElement(isolate, initial_prototype, index); | 6080 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 6072 RETURN_IF_EMPTY_HANDLE(isolate, result); | 6081 isolate, result, |
| 6082 Object::GetElement(isolate, initial_prototype, index)); |
| 6073 return *result; | 6083 return *result; |
| 6074 } | 6084 } |
| 6075 } | 6085 } |
| 6076 | 6086 |
| 6077 // Handle special arguments properties. | 6087 // Handle special arguments properties. |
| 6078 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); | 6088 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); |
| 6079 if (key->Equals(isolate->heap()->callee_string())) { | 6089 if (key->Equals(isolate->heap()->callee_string())) { |
| 6080 JSFunction* function = frame->function(); | 6090 JSFunction* function = frame->function(); |
| 6081 if (function->shared()->strict_mode() == STRICT) { | 6091 if (function->shared()->strict_mode() == STRICT) { |
| 6082 return isolate->Throw(*isolate->factory()->NewTypeError( | 6092 return isolate->Throw(*isolate->factory()->NewTypeError( |
| (...skipping 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8922 Handle<Object> argv_small_buffer[argv_small_size]; | 8932 Handle<Object> argv_small_buffer[argv_small_size]; |
| 8923 SmartArrayPointer<Handle<Object> > argv_large_buffer; | 8933 SmartArrayPointer<Handle<Object> > argv_large_buffer; |
| 8924 Handle<Object>* argv = argv_small_buffer; | 8934 Handle<Object>* argv = argv_small_buffer; |
| 8925 if (argc > argv_small_size) { | 8935 if (argc > argv_small_size) { |
| 8926 argv = new Handle<Object>[argc]; | 8936 argv = new Handle<Object>[argc]; |
| 8927 if (argv == NULL) return isolate->StackOverflow(); | 8937 if (argv == NULL) return isolate->StackOverflow(); |
| 8928 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); | 8938 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); |
| 8929 } | 8939 } |
| 8930 | 8940 |
| 8931 for (int i = 0; i < argc; ++i) { | 8941 for (int i = 0; i < argc; ++i) { |
| 8932 argv[i] = Object::GetElement(isolate, arguments, offset + i); | 8942 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 8933 RETURN_IF_EMPTY_HANDLE(isolate, argv[i]); | 8943 isolate, argv[i], |
| 8944 Object::GetElement(isolate, arguments, offset + i)); |
| 8934 } | 8945 } |
| 8935 | 8946 |
| 8936 bool threw; | 8947 bool threw; |
| 8937 Handle<Object> result = Execution::Call( | 8948 Handle<Object> result = Execution::Call( |
| 8938 isolate, fun, receiver, argc, argv, &threw, true); | 8949 isolate, fun, receiver, argc, argv, &threw, true); |
| 8939 | 8950 |
| 8940 if (threw) return Failure::Exception(); | 8951 if (threw) return Failure::Exception(); |
| 8941 return *result; | 8952 return *result; |
| 8942 } | 8953 } |
| 8943 | 8954 |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10273 int fast_length = static_cast<int>(length); | 10284 int fast_length = static_cast<int>(length); |
| 10274 ASSERT(fast_length <= elements->length()); | 10285 ASSERT(fast_length <= elements->length()); |
| 10275 for (int j = 0; j < fast_length; j++) { | 10286 for (int j = 0; j < fast_length; j++) { |
| 10276 HandleScope loop_scope(isolate); | 10287 HandleScope loop_scope(isolate); |
| 10277 Handle<Object> element_value(elements->get(j), isolate); | 10288 Handle<Object> element_value(elements->get(j), isolate); |
| 10278 if (!element_value->IsTheHole()) { | 10289 if (!element_value->IsTheHole()) { |
| 10279 visitor->visit(j, element_value); | 10290 visitor->visit(j, element_value); |
| 10280 } else if (JSReceiver::HasElement(receiver, j)) { | 10291 } else if (JSReceiver::HasElement(receiver, j)) { |
| 10281 // Call GetElement on receiver, not its prototype, or getters won't | 10292 // Call GetElement on receiver, not its prototype, or getters won't |
| 10282 // have the correct receiver. | 10293 // have the correct receiver. |
| 10283 element_value = Object::GetElement(isolate, receiver, j); | 10294 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 10284 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); | 10295 isolate, element_value, |
| 10296 Object::GetElement(isolate, receiver, j), |
| 10297 false); |
| 10285 visitor->visit(j, element_value); | 10298 visitor->visit(j, element_value); |
| 10286 } | 10299 } |
| 10287 } | 10300 } |
| 10288 break; | 10301 break; |
| 10289 } | 10302 } |
| 10290 case FAST_HOLEY_DOUBLE_ELEMENTS: | 10303 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 10291 case FAST_DOUBLE_ELEMENTS: { | 10304 case FAST_DOUBLE_ELEMENTS: { |
| 10292 // Run through the elements FixedArray and use HasElement and GetElement | 10305 // Run through the elements FixedArray and use HasElement and GetElement |
| 10293 // to check the prototype for missing elements. | 10306 // to check the prototype for missing elements. |
| 10294 Handle<FixedDoubleArray> elements( | 10307 Handle<FixedDoubleArray> elements( |
| 10295 FixedDoubleArray::cast(receiver->elements())); | 10308 FixedDoubleArray::cast(receiver->elements())); |
| 10296 int fast_length = static_cast<int>(length); | 10309 int fast_length = static_cast<int>(length); |
| 10297 ASSERT(fast_length <= elements->length()); | 10310 ASSERT(fast_length <= elements->length()); |
| 10298 for (int j = 0; j < fast_length; j++) { | 10311 for (int j = 0; j < fast_length; j++) { |
| 10299 HandleScope loop_scope(isolate); | 10312 HandleScope loop_scope(isolate); |
| 10300 if (!elements->is_the_hole(j)) { | 10313 if (!elements->is_the_hole(j)) { |
| 10301 double double_value = elements->get_scalar(j); | 10314 double double_value = elements->get_scalar(j); |
| 10302 Handle<Object> element_value = | 10315 Handle<Object> element_value = |
| 10303 isolate->factory()->NewNumber(double_value); | 10316 isolate->factory()->NewNumber(double_value); |
| 10304 visitor->visit(j, element_value); | 10317 visitor->visit(j, element_value); |
| 10305 } else if (JSReceiver::HasElement(receiver, j)) { | 10318 } else if (JSReceiver::HasElement(receiver, j)) { |
| 10306 // Call GetElement on receiver, not its prototype, or getters won't | 10319 // Call GetElement on receiver, not its prototype, or getters won't |
| 10307 // have the correct receiver. | 10320 // have the correct receiver. |
| 10308 Handle<Object> element_value = | 10321 Handle<Object> element_value; |
| 10309 Object::GetElement(isolate, receiver, j); | 10322 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 10310 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); | 10323 isolate, element_value, |
| 10324 Object::GetElement(isolate, receiver, j), |
| 10325 false); |
| 10311 visitor->visit(j, element_value); | 10326 visitor->visit(j, element_value); |
| 10312 } | 10327 } |
| 10313 } | 10328 } |
| 10314 break; | 10329 break; |
| 10315 } | 10330 } |
| 10316 case DICTIONARY_ELEMENTS: { | 10331 case DICTIONARY_ELEMENTS: { |
| 10317 Handle<SeededNumberDictionary> dict(receiver->element_dictionary()); | 10332 Handle<SeededNumberDictionary> dict(receiver->element_dictionary()); |
| 10318 List<uint32_t> indices(dict->Capacity() / 2); | 10333 List<uint32_t> indices(dict->Capacity() / 2); |
| 10319 // Collect all indices in the object and the prototypes less | 10334 // Collect all indices in the object and the prototypes less |
| 10320 // than length. This might introduce duplicates in the indices list. | 10335 // than length. This might introduce duplicates in the indices list. |
| 10321 CollectElementIndices(receiver, length, &indices); | 10336 CollectElementIndices(receiver, length, &indices); |
| 10322 indices.Sort(&compareUInt32); | 10337 indices.Sort(&compareUInt32); |
| 10323 int j = 0; | 10338 int j = 0; |
| 10324 int n = indices.length(); | 10339 int n = indices.length(); |
| 10325 while (j < n) { | 10340 while (j < n) { |
| 10326 HandleScope loop_scope(isolate); | 10341 HandleScope loop_scope(isolate); |
| 10327 uint32_t index = indices[j]; | 10342 uint32_t index = indices[j]; |
| 10328 Handle<Object> element = Object::GetElement(isolate, receiver, index); | 10343 Handle<Object> element; |
| 10329 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false); | 10344 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 10345 isolate, element, |
| 10346 Object::GetElement(isolate, receiver, index), |
| 10347 false); |
| 10330 visitor->visit(index, element); | 10348 visitor->visit(index, element); |
| 10331 // Skip to next different index (i.e., omit duplicates). | 10349 // Skip to next different index (i.e., omit duplicates). |
| 10332 do { | 10350 do { |
| 10333 j++; | 10351 j++; |
| 10334 } while (j < n && indices[j] == index); | 10352 } while (j < n && indices[j] == index); |
| 10335 } | 10353 } |
| 10336 break; | 10354 break; |
| 10337 } | 10355 } |
| 10338 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: { | 10356 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: { |
| 10339 Handle<ExternalUint8ClampedArray> pixels(ExternalUint8ClampedArray::cast( | 10357 Handle<ExternalUint8ClampedArray> pixels(ExternalUint8ClampedArray::cast( |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10662 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { | 10680 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { |
| 10663 // Bail out if we find a proxy or interceptor, likely not worth | 10681 // Bail out if we find a proxy or interceptor, likely not worth |
| 10664 // collecting keys in that case. | 10682 // collecting keys in that case. |
| 10665 return *isolate->factory()->NewNumberFromUint(length); | 10683 return *isolate->factory()->NewNumberFromUint(length); |
| 10666 } | 10684 } |
| 10667 Handle<JSObject> current = Handle<JSObject>::cast(p); | 10685 Handle<JSObject> current = Handle<JSObject>::cast(p); |
| 10668 Handle<FixedArray> current_keys = | 10686 Handle<FixedArray> current_keys = |
| 10669 isolate->factory()->NewFixedArray( | 10687 isolate->factory()->NewFixedArray( |
| 10670 current->NumberOfLocalElements(NONE)); | 10688 current->NumberOfLocalElements(NONE)); |
| 10671 current->GetLocalElementKeys(*current_keys, NONE); | 10689 current->GetLocalElementKeys(*current_keys, NONE); |
| 10672 keys = FixedArray::UnionOfKeys(keys, current_keys); | 10690 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10691 isolate, keys, FixedArray::UnionOfKeys(keys, current_keys)); |
| 10673 } | 10692 } |
| 10674 // Erase any keys >= length. | 10693 // Erase any keys >= length. |
| 10675 // TODO(adamk): Remove this step when the contract of %GetArrayKeys | 10694 // TODO(adamk): Remove this step when the contract of %GetArrayKeys |
| 10676 // is changed to let this happen on the JS side. | 10695 // is changed to let this happen on the JS side. |
| 10677 for (int i = 0; i < keys->length(); i++) { | 10696 for (int i = 0; i < keys->length(); i++) { |
| 10678 if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); | 10697 if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); |
| 10679 } | 10698 } |
| 10680 return *isolate->factory()->NewJSArrayWithElements(keys); | 10699 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 10681 } else { | 10700 } else { |
| 10682 ASSERT(array->HasFastSmiOrObjectElements() || | 10701 ASSERT(array->HasFastSmiOrObjectElements() || |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10844 if (obj->IsJSGlobalProxy()) { | 10863 if (obj->IsJSGlobalProxy()) { |
| 10845 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); | 10864 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); |
| 10846 } | 10865 } |
| 10847 | 10866 |
| 10848 | 10867 |
| 10849 // Check if the name is trivially convertible to an index and get the element | 10868 // Check if the name is trivially convertible to an index and get the element |
| 10850 // if so. | 10869 // if so. |
| 10851 uint32_t index; | 10870 uint32_t index; |
| 10852 if (name->AsArrayIndex(&index)) { | 10871 if (name->AsArrayIndex(&index)) { |
| 10853 Handle<FixedArray> details = isolate->factory()->NewFixedArray(2); | 10872 Handle<FixedArray> details = isolate->factory()->NewFixedArray(2); |
| 10854 Handle<Object> element_or_char = | 10873 Handle<Object> element_or_char; |
| 10855 Runtime::GetElementOrCharAt(isolate, obj, index); | 10874 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10856 RETURN_IF_EMPTY_HANDLE(isolate, element_or_char); | 10875 isolate, element_or_char, |
| 10876 Runtime::GetElementOrCharAt(isolate, obj, index)); |
| 10857 details->set(0, *element_or_char); | 10877 details->set(0, *element_or_char); |
| 10858 details->set( | 10878 details->set( |
| 10859 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi()); | 10879 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi()); |
| 10860 return *isolate->factory()->NewJSArrayWithElements(details); | 10880 return *isolate->factory()->NewJSArrayWithElements(details); |
| 10861 } | 10881 } |
| 10862 | 10882 |
| 10863 // Find the number of objects making up this. | 10883 // Find the number of objects making up this. |
| 10864 int length = LocalPrototypeChainLength(*obj); | 10884 int length = LocalPrototypeChainLength(*obj); |
| 10865 | 10885 |
| 10866 // Try local lookup on each of the objects. | 10886 // Try local lookup on each of the objects. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10984 | 11004 |
| 10985 // Return element value from indexed interceptor. | 11005 // Return element value from indexed interceptor. |
| 10986 // args[0]: object | 11006 // args[0]: object |
| 10987 // args[1]: index | 11007 // args[1]: index |
| 10988 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { | 11008 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { |
| 10989 HandleScope scope(isolate); | 11009 HandleScope scope(isolate); |
| 10990 ASSERT(args.length() == 2); | 11010 ASSERT(args.length() == 2); |
| 10991 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 11011 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10992 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | 11012 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); |
| 10993 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | 11013 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); |
| 10994 Handle<Object> result = JSObject::GetElementWithInterceptor(obj, obj, index); | 11014 Handle<Object> result; |
| 10995 RETURN_IF_EMPTY_HANDLE(isolate, result); | 11015 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 11016 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); |
| 10996 return *result; | 11017 return *result; |
| 10997 } | 11018 } |
| 10998 | 11019 |
| 10999 | 11020 |
| 11000 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { | 11021 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { |
| 11001 SealHandleScope shs(isolate); | 11022 SealHandleScope shs(isolate); |
| 11002 ASSERT(args.length() >= 1); | 11023 ASSERT(args.length() >= 1); |
| 11003 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11024 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 11004 // Check that the break id is valid. | 11025 // Check that the break id is valid. |
| 11005 if (isolate->debug()->break_id() == 0 || | 11026 if (isolate->debug()->break_id() == 0 || |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11475 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11496 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 11476 | 11497 |
| 11477 // Parameters. | 11498 // Parameters. |
| 11478 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11499 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 11479 // Shadowed parameters were not materialized. | 11500 // Shadowed parameters were not materialized. |
| 11480 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; | 11501 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; |
| 11481 | 11502 |
| 11482 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11503 ASSERT(!frame->GetParameter(i)->IsTheHole()); |
| 11483 HandleScope scope(isolate); | 11504 HandleScope scope(isolate); |
| 11484 Handle<String> name(scope_info->ParameterName(i)); | 11505 Handle<String> name(scope_info->ParameterName(i)); |
| 11485 Handle<Object> value = Object::GetPropertyOrElement(target, name); | 11506 Handle<Object> value = |
| 11507 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
| 11486 frame->SetParameterValue(i, *value); | 11508 frame->SetParameterValue(i, *value); |
| 11487 } | 11509 } |
| 11488 | 11510 |
| 11489 // Stack locals. | 11511 // Stack locals. |
| 11490 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11512 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 11491 if (frame->GetExpression(i)->IsTheHole()) continue; | 11513 if (frame->GetExpression(i)->IsTheHole()) continue; |
| 11492 HandleScope scope(isolate); | 11514 HandleScope scope(isolate); |
| 11493 Handle<Object> value = Object::GetPropertyOrElement( | 11515 Handle<Object> value = Object::GetPropertyOrElement( |
| 11494 target, Handle<String>(scope_info->StackLocalName(i))); | 11516 target, |
| 11517 handle(scope_info->StackLocalName(i), isolate)).ToHandleChecked(); |
| 11495 frame->SetExpression(i, *value); | 11518 frame->SetExpression(i, *value); |
| 11496 } | 11519 } |
| 11497 } | 11520 } |
| 11498 | 11521 |
| 11499 | 11522 |
| 11500 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( | 11523 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( |
| 11501 Isolate* isolate, | 11524 Isolate* isolate, |
| 11502 Handle<JSObject> target, | 11525 Handle<JSObject> target, |
| 11503 Handle<JSFunction> function, | 11526 Handle<JSFunction> function, |
| 11504 JavaScriptFrame* frame) { | 11527 JavaScriptFrame* frame) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 11515 scope_info, function_context, target)) { | 11538 scope_info, function_context, target)) { |
| 11516 return MaybeHandle<JSObject>(); | 11539 return MaybeHandle<JSObject>(); |
| 11517 } | 11540 } |
| 11518 | 11541 |
| 11519 // Finally copy any properties from the function context extension. | 11542 // Finally copy any properties from the function context extension. |
| 11520 // These will be variables introduced by eval. | 11543 // These will be variables introduced by eval. |
| 11521 if (function_context->closure() == *function) { | 11544 if (function_context->closure() == *function) { |
| 11522 if (function_context->has_extension() && | 11545 if (function_context->has_extension() && |
| 11523 !function_context->IsNativeContext()) { | 11546 !function_context->IsNativeContext()) { |
| 11524 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 11547 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
| 11525 bool threw = false; | 11548 Handle<FixedArray> keys; |
| 11526 Handle<FixedArray> keys = | 11549 ASSIGN_RETURN_ON_EXCEPTION( |
| 11527 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11550 isolate, keys, GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS), JSObject); |
| 11528 if (threw) return Handle<JSObject>(); | |
| 11529 | 11551 |
| 11530 for (int i = 0; i < keys->length(); i++) { | 11552 for (int i = 0; i < keys->length(); i++) { |
| 11531 // Names of variables introduced by eval are strings. | 11553 // Names of variables introduced by eval are strings. |
| 11532 ASSERT(keys->get(i)->IsString()); | 11554 ASSERT(keys->get(i)->IsString()); |
| 11533 Handle<String> key(String::cast(keys->get(i))); | 11555 Handle<String> key(String::cast(keys->get(i))); |
| 11556 Handle<Object> value; |
| 11557 ASSIGN_RETURN_ON_EXCEPTION( |
| 11558 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
| 11534 RETURN_ON_EXCEPTION( | 11559 RETURN_ON_EXCEPTION( |
| 11535 isolate, | 11560 isolate, |
| 11536 Runtime::SetObjectProperty(isolate, | 11561 Runtime::SetObjectProperty( |
| 11537 target, | 11562 isolate, target, key, value, NONE, SLOPPY), |
| 11538 key, | |
| 11539 Object::GetPropertyOrElement(ext, key), | |
| 11540 NONE, | |
| 11541 SLOPPY), | |
| 11542 JSObject); | 11563 JSObject); |
| 11543 } | 11564 } |
| 11544 } | 11565 } |
| 11545 } | 11566 } |
| 11546 | 11567 |
| 11547 return target; | 11568 return target; |
| 11548 } | 11569 } |
| 11549 | 11570 |
| 11550 | 11571 |
| 11551 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( | 11572 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11670 // Fill all context locals to the context extension. | 11691 // Fill all context locals to the context extension. |
| 11671 if (!ScopeInfo::CopyContextLocalsToScopeObject( | 11692 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
| 11672 scope_info, context, closure_scope)) { | 11693 scope_info, context, closure_scope)) { |
| 11673 return MaybeHandle<JSObject>(); | 11694 return MaybeHandle<JSObject>(); |
| 11674 } | 11695 } |
| 11675 | 11696 |
| 11676 // Finally copy any properties from the function context extension. This will | 11697 // Finally copy any properties from the function context extension. This will |
| 11677 // be variables introduced by eval. | 11698 // be variables introduced by eval. |
| 11678 if (context->has_extension()) { | 11699 if (context->has_extension()) { |
| 11679 Handle<JSObject> ext(JSObject::cast(context->extension())); | 11700 Handle<JSObject> ext(JSObject::cast(context->extension())); |
| 11680 bool threw = false; | 11701 Handle<FixedArray> keys; |
| 11681 Handle<FixedArray> keys = | 11702 ASSIGN_RETURN_ON_EXCEPTION( |
| 11682 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11703 isolate, keys, GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS), JSObject); |
| 11683 if (threw) return Handle<JSObject>(); | |
| 11684 | 11704 |
| 11685 for (int i = 0; i < keys->length(); i++) { | 11705 for (int i = 0; i < keys->length(); i++) { |
| 11706 HandleScope scope(isolate); |
| 11686 // Names of variables introduced by eval are strings. | 11707 // Names of variables introduced by eval are strings. |
| 11687 ASSERT(keys->get(i)->IsString()); | 11708 ASSERT(keys->get(i)->IsString()); |
| 11688 Handle<String> key(String::cast(keys->get(i))); | 11709 Handle<String> key(String::cast(keys->get(i))); |
| 11689 RETURN_ON_EXCEPTION( | 11710 Handle<Object> value; |
| 11711 ASSIGN_RETURN_ON_EXCEPTION( |
| 11712 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
| 11713 RETURN_ON_EXCEPTION( |
| 11690 isolate, | 11714 isolate, |
| 11691 Runtime::SetObjectProperty(isolate, closure_scope, key, | 11715 Runtime::SetObjectProperty( |
| 11692 Object::GetPropertyOrElement(ext, key), | 11716 isolate, closure_scope, key, value, NONE, SLOPPY), |
| 11693 NONE, SLOPPY), | |
| 11694 JSObject); | 11717 JSObject); |
| 11695 } | 11718 } |
| 11696 } | 11719 } |
| 11697 | 11720 |
| 11698 return closure_scope; | 11721 return closure_scope; |
| 11699 } | 11722 } |
| 11700 | 11723 |
| 11701 | 11724 |
| 11702 // This method copies structure of MaterializeClosure method above. | 11725 // This method copies structure of MaterializeClosure method above. |
| 11703 static bool SetClosureVariableValue(Isolate* isolate, | 11726 static bool SetClosureVariableValue(Isolate* isolate, |
| (...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13801 | 13824 |
| 13802 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); | 13825 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); |
| 13803 | 13826 |
| 13804 uint32_t length = static_cast<uint32_t>(input->length()->Number()); | 13827 uint32_t length = static_cast<uint32_t>(input->length()->Number()); |
| 13805 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length); | 13828 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length); |
| 13806 Handle<Name> maximized = | 13829 Handle<Name> maximized = |
| 13807 isolate->factory()->NewStringFromAscii(CStrVector("maximized")); | 13830 isolate->factory()->NewStringFromAscii(CStrVector("maximized")); |
| 13808 Handle<Name> base = | 13831 Handle<Name> base = |
| 13809 isolate->factory()->NewStringFromAscii(CStrVector("base")); | 13832 isolate->factory()->NewStringFromAscii(CStrVector("base")); |
| 13810 for (unsigned int i = 0; i < length; ++i) { | 13833 for (unsigned int i = 0; i < length; ++i) { |
| 13811 Handle<Object> locale_id = Object::GetElement(isolate, input, i); | 13834 Handle<Object> locale_id; |
| 13812 RETURN_IF_EMPTY_HANDLE(isolate, locale_id); | 13835 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13836 isolate, locale_id, Object::GetElement(isolate, input, i)); |
| 13813 if (!locale_id->IsString()) { | 13837 if (!locale_id->IsString()) { |
| 13814 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13838 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
| 13815 } | 13839 } |
| 13816 | 13840 |
| 13817 v8::String::Utf8Value utf8_locale_id( | 13841 v8::String::Utf8Value utf8_locale_id( |
| 13818 v8::Utils::ToLocal(Handle<String>::cast(locale_id))); | 13842 v8::Utils::ToLocal(Handle<String>::cast(locale_id))); |
| 13819 | 13843 |
| 13820 UErrorCode error = U_ZERO_ERROR; | 13844 UErrorCode error = U_ZERO_ERROR; |
| 13821 | 13845 |
| 13822 // Convert from BCP47 to ICU format. | 13846 // Convert from BCP47 to ICU format. |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15214 } | 15238 } |
| 15215 } | 15239 } |
| 15216 | 15240 |
| 15217 | 15241 |
| 15218 void Runtime::OutOfMemory() { | 15242 void Runtime::OutOfMemory() { |
| 15219 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15243 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
| 15220 UNREACHABLE(); | 15244 UNREACHABLE(); |
| 15221 } | 15245 } |
| 15222 | 15246 |
| 15223 } } // namespace v8::internal | 15247 } } // namespace v8::internal |
| OLD | NEW |