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 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2937 Accessors::FunctionSetPrototype(fun, value); | 2937 Accessors::FunctionSetPrototype(fun, value); |
2938 return args[0]; // return TOS | 2938 return args[0]; // return TOS |
2939 } | 2939 } |
2940 | 2940 |
2941 | 2941 |
2942 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2942 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
2943 HandleScope shs(isolate); | 2943 HandleScope shs(isolate); |
2944 RUNTIME_ASSERT(args.length() == 1); | 2944 RUNTIME_ASSERT(args.length() == 1); |
2945 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 2945 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
2946 | 2946 |
2947 String* name = isolate->heap()->prototype_string(); | 2947 Handle<String> name = isolate->factory()->prototype_string(); |
2948 | 2948 |
2949 if (function->HasFastProperties()) { | 2949 if (function->HasFastProperties()) { |
2950 // Construct a new field descriptor with updated attributes. | 2950 // Construct a new field descriptor with updated attributes. |
2951 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2951 Handle<DescriptorArray> instance_desc = |
2952 handle(function->map()->instance_descriptors()); | |
2952 | 2953 |
2953 int index = instance_desc->SearchWithCache(name, function->map()); | 2954 int index = instance_desc->SearchWithCache(*name, function->map()); |
2954 ASSERT(index != DescriptorArray::kNotFound); | 2955 ASSERT(index != DescriptorArray::kNotFound); |
2955 PropertyDetails details = instance_desc->GetDetails(index); | 2956 PropertyDetails details = instance_desc->GetDetails(index); |
2956 | 2957 |
2957 CallbacksDescriptor new_desc(name, | 2958 CallbacksDescriptor new_desc( |
2958 instance_desc->GetValue(index), | 2959 name, |
2960 handle(instance_desc->GetValue(index), isolate), | |
2959 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY)); | 2961 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY)); |
2960 | 2962 |
2961 // Create a new map featuring the new field descriptors array. | 2963 // Create a new map featuring the new field descriptors array. |
2962 Map* new_map; | 2964 Handle<Map> map = handle(function->map()); |
2963 MaybeObject* maybe_map = | 2965 Handle<Map> new_map = Map::CopyReplaceDescriptor(map, |
mvstanton
2014/04/09 14:26:06
All args on a new line.
| |
2964 function->map()->CopyReplaceDescriptor( | |
2965 instance_desc, &new_desc, index, OMIT_TRANSITION); | 2966 instance_desc, &new_desc, index, OMIT_TRANSITION); |
2966 if (!maybe_map->To(&new_map)) return maybe_map; | |
2967 | 2967 |
2968 JSObject::MigrateToMap(function, handle(new_map)); | 2968 JSObject::MigrateToMap(function, new_map); |
2969 } else { // Dictionary properties. | 2969 } else { // Dictionary properties. |
2970 // Directly manipulate the property details. | 2970 // Directly manipulate the property details. |
2971 DisallowHeapAllocation no_gc; | 2971 DisallowHeapAllocation no_gc; |
2972 int entry = function->property_dictionary()->FindEntry(name); | 2972 int entry = function->property_dictionary()->FindEntry(*name); |
2973 ASSERT(entry != NameDictionary::kNotFound); | 2973 ASSERT(entry != NameDictionary::kNotFound); |
2974 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); | 2974 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); |
2975 PropertyDetails new_details( | 2975 PropertyDetails new_details( |
2976 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2976 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
2977 details.type(), | 2977 details.type(), |
2978 details.dictionary_index()); | 2978 details.dictionary_index()); |
2979 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2979 function->property_dictionary()->DetailsAtPut(entry, new_details); |
2980 } | 2980 } |
2981 return *function; | 2981 return *function; |
2982 } | 2982 } |
(...skipping 12239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15222 } | 15222 } |
15223 } | 15223 } |
15224 | 15224 |
15225 | 15225 |
15226 void Runtime::OutOfMemory() { | 15226 void Runtime::OutOfMemory() { |
15227 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15227 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15228 UNREACHABLE(); | 15228 UNREACHABLE(); |
15229 } | 15229 } |
15230 | 15230 |
15231 } } // namespace v8::internal | 15231 } } // namespace v8::internal |
OLD | NEW |