| 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 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   1655 static bool CheckAccessException(Object* callback, |   1655 static bool CheckAccessException(Object* callback, | 
|   1656                                  v8::AccessType access_type) { |   1656                                  v8::AccessType access_type) { | 
|   1657   if (callback->IsAccessorInfo()) { |   1657   if (callback->IsAccessorInfo()) { | 
|   1658     AccessorInfo* info = AccessorInfo::cast(callback); |   1658     AccessorInfo* info = AccessorInfo::cast(callback); | 
|   1659     return |   1659     return | 
|   1660         (access_type == v8::ACCESS_HAS && |   1660         (access_type == v8::ACCESS_HAS && | 
|   1661            (info->all_can_read() || info->all_can_write())) || |   1661            (info->all_can_read() || info->all_can_write())) || | 
|   1662         (access_type == v8::ACCESS_GET && info->all_can_read()) || |   1662         (access_type == v8::ACCESS_GET && info->all_can_read()) || | 
|   1663         (access_type == v8::ACCESS_SET && info->all_can_write()); |   1663         (access_type == v8::ACCESS_SET && info->all_can_write()); | 
|   1664   } |   1664   } | 
 |   1665   if (callback->IsAccessorPair()) { | 
 |   1666     AccessorPair* info = AccessorPair::cast(callback); | 
 |   1667     return | 
 |   1668         (access_type == v8::ACCESS_HAS && | 
 |   1669            (info->all_can_read() || info->all_can_write())) || | 
 |   1670         (access_type == v8::ACCESS_GET && info->all_can_read()) || | 
 |   1671         (access_type == v8::ACCESS_SET && info->all_can_write()); | 
 |   1672   } | 
|   1665   return false; |   1673   return false; | 
|   1666 } |   1674 } | 
|   1667  |   1675  | 
|   1668  |   1676  | 
|   1669 template<class Key> |   1677 template<class Key> | 
|   1670 static bool CheckGenericAccess( |   1678 static bool CheckGenericAccess( | 
|   1671     JSObject* receiver, |   1679     JSObject* receiver, | 
|   1672     JSObject* holder, |   1680     JSObject* holder, | 
|   1673     Key key, |   1681     Key key, | 
|   1674     v8::AccessType access_type, |   1682     v8::AccessType access_type, | 
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   1936     MaybeObject* maybe_new_map = old_map->Copy(); |   1944     MaybeObject* maybe_new_map = old_map->Copy(); | 
|   1937     if (!maybe_new_map->To(&new_map)) return maybe_new_map; |   1945     if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 
|   1938  |   1946  | 
|   1939     new_map->set_is_access_check_needed(true); |   1947     new_map->set_is_access_check_needed(true); | 
|   1940     object->set_map(new_map); |   1948     object->set_map(new_map); | 
|   1941   } |   1949   } | 
|   1942   return isolate->heap()->undefined_value(); |   1950   return isolate->heap()->undefined_value(); | 
|   1943 } |   1951 } | 
|   1944  |   1952  | 
|   1945  |   1953  | 
 |   1954 // Transform getter or setter into something DefineAccessor can handle. | 
 |   1955 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, | 
 |   1956                                                    Handle<Object> component) { | 
 |   1957   if (component->IsUndefined()) return isolate->factory()->null_value(); | 
 |   1958   Handle<FunctionTemplateInfo> info = | 
 |   1959       Handle<FunctionTemplateInfo>::cast(component); | 
 |   1960   return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); | 
 |   1961 } | 
 |   1962  | 
 |   1963  | 
 |   1964 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) { | 
 |   1965   HandleScope scope(isolate); | 
 |   1966   ASSERT(args.length() == 6); | 
 |   1967   CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 
 |   1968   CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 
 |   1969   CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 
 |   1970   CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 
 |   1971   CONVERT_SMI_ARG_CHECKED(attribute, 4); | 
 |   1972   CONVERT_SMI_ARG_CHECKED(access_control, 5); | 
 |   1973   JSObject::DefineAccessor(object, | 
 |   1974                            name, | 
 |   1975                            InstantiateAccessorComponent(isolate, getter), | 
 |   1976                            InstantiateAccessorComponent(isolate, setter), | 
 |   1977                            static_cast<PropertyAttributes>(attribute), | 
 |   1978                            static_cast<v8::AccessControl>(access_control)); | 
 |   1979   return isolate->heap()->undefined_value(); | 
 |   1980 } | 
 |   1981  | 
 |   1982  | 
|   1946 static Failure* ThrowRedeclarationError(Isolate* isolate, |   1983 static Failure* ThrowRedeclarationError(Isolate* isolate, | 
|   1947                                         const char* type, |   1984                                         const char* type, | 
|   1948                                         Handle<String> name) { |   1985                                         Handle<String> name) { | 
|   1949   HandleScope scope(isolate); |   1986   HandleScope scope(isolate); | 
|   1950   Handle<Object> type_handle = |   1987   Handle<Object> type_handle = | 
|   1951       isolate->factory()->NewStringFromAscii(CStrVector(type)); |   1988       isolate->factory()->NewStringFromAscii(CStrVector(type)); | 
|   1952   Handle<Object> args[2] = { type_handle, name }; |   1989   Handle<Object> args[2] = { type_handle, name }; | 
|   1953   Handle<Object> error = |   1990   Handle<Object> error = | 
|   1954       isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); |   1991       isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); | 
|   1955   return isolate->Throw(*error); |   1992   return isolate->Throw(*error); | 
| (...skipping 12680 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  14636     // Handle last resort GC and make sure to allow future allocations |  14673     // Handle last resort GC and make sure to allow future allocations | 
|  14637     // to grow the heap without causing GCs (if possible). |  14674     // to grow the heap without causing GCs (if possible). | 
|  14638     isolate->counters()->gc_last_resort_from_js()->Increment(); |  14675     isolate->counters()->gc_last_resort_from_js()->Increment(); | 
|  14639     isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |  14676     isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 
|  14640                                        "Runtime::PerformGC"); |  14677                                        "Runtime::PerformGC"); | 
|  14641   } |  14678   } | 
|  14642 } |  14679 } | 
|  14643  |  14680  | 
|  14644  |  14681  | 
|  14645 } }  // namespace v8::internal |  14682 } }  // namespace v8::internal | 
| OLD | NEW |