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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 static bool CheckAccessException(Object* callback, | 1657 static bool CheckAccessException(Object* callback, |
1658 v8::AccessType access_type) { | 1658 v8::AccessType access_type) { |
1659 if (callback->IsAccessorInfo()) { | 1659 if (callback->IsAccessorInfo()) { |
1660 AccessorInfo* info = AccessorInfo::cast(callback); | 1660 AccessorInfo* info = AccessorInfo::cast(callback); |
1661 return | 1661 return |
1662 (access_type == v8::ACCESS_HAS && | 1662 (access_type == v8::ACCESS_HAS && |
1663 (info->all_can_read() || info->all_can_write())) || | 1663 (info->all_can_read() || info->all_can_write())) || |
1664 (access_type == v8::ACCESS_GET && info->all_can_read()) || | 1664 (access_type == v8::ACCESS_GET && info->all_can_read()) || |
1665 (access_type == v8::ACCESS_SET && info->all_can_write()); | 1665 (access_type == v8::ACCESS_SET && info->all_can_write()); |
1666 } | 1666 } |
1667 if (callback->IsAccessorPair()) { | |
1668 AccessorPair* info = AccessorPair::cast(callback); | |
1669 return | |
1670 (access_type == v8::ACCESS_HAS && | |
1671 (info->all_can_read() || info->all_can_write())) || | |
1672 (access_type == v8::ACCESS_GET && info->all_can_read()) || | |
1673 (access_type == v8::ACCESS_SET && info->all_can_write()); | |
1674 } | |
1667 return false; | 1675 return false; |
1668 } | 1676 } |
1669 | 1677 |
1670 | 1678 |
1671 template<class Key> | 1679 template<class Key> |
1672 static bool CheckGenericAccess( | 1680 static bool CheckGenericAccess( |
1673 JSObject* receiver, | 1681 JSObject* receiver, |
1674 JSObject* holder, | 1682 JSObject* holder, |
1675 Key key, | 1683 Key key, |
1676 v8::AccessType access_type, | 1684 v8::AccessType access_type, |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1938 MaybeObject* maybe_new_map = old_map->Copy(); | 1946 MaybeObject* maybe_new_map = old_map->Copy(); |
1939 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1947 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
1940 | 1948 |
1941 new_map->set_is_access_check_needed(true); | 1949 new_map->set_is_access_check_needed(true); |
1942 object->set_map(new_map); | 1950 object->set_map(new_map); |
1943 } | 1951 } |
1944 return isolate->heap()->undefined_value(); | 1952 return isolate->heap()->undefined_value(); |
1945 } | 1953 } |
1946 | 1954 |
1947 | 1955 |
1956 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) { | |
1957 HandleScope scope(isolate); | |
1958 ASSERT(args.length() == 6); | |
1959 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | |
1960 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | |
1961 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | |
1962 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | |
1963 CONVERT_SMI_ARG_CHECKED(attribute, 4); | |
1964 CONVERT_SMI_ARG_CHECKED(access_control, 5); | |
1965 // Transform getter into something DefineAccessor can handle. | |
1966 if (getter->IsUndefined()) { | |
Sven Panne
2013/08/22 08:52:51
Tiny nit: Can we extract this if/then/else into a
| |
1967 getter = isolate->factory()->null_value(); | |
1968 } else { | |
1969 Handle<FunctionTemplateInfo> info = | |
1970 Handle<FunctionTemplateInfo>::cast(getter); | |
1971 getter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); | |
1972 } | |
1973 // Transform getter into something DefineAccessor can handle. | |
1974 if (setter->IsUndefined()) { | |
1975 setter = isolate->factory()->null_value(); | |
1976 } else { | |
1977 Handle<FunctionTemplateInfo> info = | |
1978 Handle<FunctionTemplateInfo>::cast(setter); | |
1979 setter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); | |
1980 } | |
1981 JSObject::DefineAccessor(object, | |
1982 name, | |
1983 getter, | |
1984 setter, | |
1985 static_cast<PropertyAttributes>(attribute), | |
1986 static_cast<v8::AccessControl>(access_control)); | |
1987 return isolate->heap()->undefined_value(); | |
1988 } | |
1989 | |
1990 | |
1948 static Failure* ThrowRedeclarationError(Isolate* isolate, | 1991 static Failure* ThrowRedeclarationError(Isolate* isolate, |
1949 const char* type, | 1992 const char* type, |
1950 Handle<String> name) { | 1993 Handle<String> name) { |
1951 HandleScope scope(isolate); | 1994 HandleScope scope(isolate); |
1952 Handle<Object> type_handle = | 1995 Handle<Object> type_handle = |
1953 isolate->factory()->NewStringFromAscii(CStrVector(type)); | 1996 isolate->factory()->NewStringFromAscii(CStrVector(type)); |
1954 Handle<Object> args[2] = { type_handle, name }; | 1997 Handle<Object> args[2] = { type_handle, name }; |
1955 Handle<Object> error = | 1998 Handle<Object> error = |
1956 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); | 1999 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); |
1957 return isolate->Throw(*error); | 2000 return isolate->Throw(*error); |
(...skipping 12683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14641 // Handle last resort GC and make sure to allow future allocations | 14684 // Handle last resort GC and make sure to allow future allocations |
14642 // to grow the heap without causing GCs (if possible). | 14685 // to grow the heap without causing GCs (if possible). |
14643 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14686 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14644 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14687 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14645 "Runtime::PerformGC"); | 14688 "Runtime::PerformGC"); |
14646 } | 14689 } |
14647 } | 14690 } |
14648 | 14691 |
14649 | 14692 |
14650 } } // namespace v8::internal | 14693 } } // namespace v8::internal |
OLD | NEW |