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 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 Accessors::FunctionSetPrototype(fun, value); | 2950 Accessors::FunctionSetPrototype(fun, value); |
2951 return args[0]; // return TOS | 2951 return args[0]; // return TOS |
2952 } | 2952 } |
2953 | 2953 |
2954 | 2954 |
2955 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2955 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
2956 HandleScope shs(isolate); | 2956 HandleScope shs(isolate); |
2957 RUNTIME_ASSERT(args.length() == 1); | 2957 RUNTIME_ASSERT(args.length() == 1); |
2958 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 2958 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
2959 | 2959 |
2960 String* name = isolate->heap()->prototype_string(); | 2960 Handle<String> name = isolate->factory()->prototype_string(); |
2961 | 2961 |
2962 if (function->HasFastProperties()) { | 2962 if (function->HasFastProperties()) { |
2963 // Construct a new field descriptor with updated attributes. | 2963 // Construct a new field descriptor with updated attributes. |
2964 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2964 Handle<DescriptorArray> instance_desc = |
| 2965 handle(function->map()->instance_descriptors()); |
2965 | 2966 |
2966 int index = instance_desc->SearchWithCache(name, function->map()); | 2967 int index = instance_desc->SearchWithCache(*name, function->map()); |
2967 ASSERT(index != DescriptorArray::kNotFound); | 2968 ASSERT(index != DescriptorArray::kNotFound); |
2968 PropertyDetails details = instance_desc->GetDetails(index); | 2969 PropertyDetails details = instance_desc->GetDetails(index); |
2969 | 2970 |
2970 CallbacksDescriptor new_desc(name, | 2971 CallbacksDescriptor new_desc( |
2971 instance_desc->GetValue(index), | 2972 name, |
| 2973 handle(instance_desc->GetValue(index), isolate), |
2972 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY)); | 2974 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY)); |
2973 | 2975 |
2974 // Create a new map featuring the new field descriptors array. | 2976 // Create a new map featuring the new field descriptors array. |
2975 Map* new_map; | 2977 Handle<Map> map = handle(function->map()); |
2976 MaybeObject* maybe_map = | 2978 Handle<Map> new_map = Map::CopyReplaceDescriptor(map, |
2977 function->map()->CopyReplaceDescriptor( | |
2978 instance_desc, &new_desc, index, OMIT_TRANSITION); | 2979 instance_desc, &new_desc, index, OMIT_TRANSITION); |
2979 if (!maybe_map->To(&new_map)) return maybe_map; | |
2980 | 2980 |
2981 JSObject::MigrateToMap(function, handle(new_map)); | 2981 JSObject::MigrateToMap(function, new_map); |
2982 } else { // Dictionary properties. | 2982 } else { // Dictionary properties. |
2983 // Directly manipulate the property details. | 2983 // Directly manipulate the property details. |
2984 DisallowHeapAllocation no_gc; | 2984 DisallowHeapAllocation no_gc; |
2985 int entry = function->property_dictionary()->FindEntry(name); | 2985 int entry = function->property_dictionary()->FindEntry(*name); |
2986 ASSERT(entry != NameDictionary::kNotFound); | 2986 ASSERT(entry != NameDictionary::kNotFound); |
2987 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); | 2987 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); |
2988 PropertyDetails new_details( | 2988 PropertyDetails new_details( |
2989 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2989 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
2990 details.type(), | 2990 details.type(), |
2991 details.dictionary_index()); | 2991 details.dictionary_index()); |
2992 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2992 function->property_dictionary()->DetailsAtPut(entry, new_details); |
2993 } | 2993 } |
2994 return *function; | 2994 return *function; |
2995 } | 2995 } |
(...skipping 12262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15258 } | 15258 } |
15259 } | 15259 } |
15260 | 15260 |
15261 | 15261 |
15262 void Runtime::OutOfMemory() { | 15262 void Runtime::OutOfMemory() { |
15263 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15263 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15264 UNREACHABLE(); | 15264 UNREACHABLE(); |
15265 } | 15265 } |
15266 | 15266 |
15267 } } // namespace v8::internal | 15267 } } // namespace v8::internal |
OLD | NEW |