Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1953 ASSERT(fun->should_have_prototype()); | 1953 ASSERT(fun->should_have_prototype()); |
| 1954 Object* obj; | 1954 Object* obj; |
| 1955 { MaybeObject* maybe_obj = | 1955 { MaybeObject* maybe_obj = |
| 1956 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 1956 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
| 1957 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1957 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1958 } | 1958 } |
| 1959 return args[0]; // return TOS | 1959 return args[0]; // return TOS |
| 1960 } | 1960 } |
| 1961 | 1961 |
| 1962 | 1962 |
| 1963 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionReadOnlyPrototype) { | |
| 1964 NoHandleAllocation ha; | |
| 1965 RUNTIME_ASSERT(args.length() == 1); | |
| 1966 CONVERT_CHECKED(JSFunction, object, args[0]); | |
|
Rico
2011/07/25 13:05:42
it's a function, maybe call it fun, function or f
Jakob Kummerow
2011/07/25 14:57:05
Done.
| |
| 1967 | |
| 1968 MaybeObject* maybe_name = | |
| 1969 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype")); | |
| 1970 String* name; | |
| 1971 if (!maybe_name->To(&name)) return maybe_name; | |
| 1972 | |
| 1973 if (object->HasFastProperties()) { | |
|
Rico
2011/07/25 13:05:42
If it is not performance critical to keep fast pro
Jakob Kummerow
2011/07/25 14:57:05
I'd prefer to keep performance as it is since this
| |
| 1974 // Construct a new field descriptor with updated attributes. | |
| 1975 DescriptorArray* instance_desc = object->map()->instance_descriptors(); | |
| 1976 int index = instance_desc->Search(name); | |
|
Rico
2011/07/25 13:05:42
assert that index != kNotFound
Jakob Kummerow
2011/07/25 14:57:05
Done.
| |
| 1977 PropertyDetails details(instance_desc->GetDetails(index)); | |
| 1978 CallbacksDescriptor new_desc(name, | |
| 1979 instance_desc->GetValue(index), | |
| 1980 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | |
| 1981 details.index()); | |
| 1982 // Construct a new field descriptors array containing the new descriptor. | |
| 1983 Object* descriptors_unchecked; | |
| 1984 { MaybeObject* maybe_descriptors_unchecked = | |
| 1985 instance_desc->CopyInsert(&new_desc, REMOVE_TRANSITIONS); | |
| 1986 if (!maybe_descriptors_unchecked->ToObject(&descriptors_unchecked)) { | |
| 1987 return maybe_descriptors_unchecked; | |
| 1988 } | |
| 1989 } | |
| 1990 DescriptorArray* new_descriptors = | |
| 1991 DescriptorArray::cast(descriptors_unchecked); | |
| 1992 // Create a new map featuring the new field descriptors array. | |
| 1993 Object* map_unchecked; | |
| 1994 { MaybeObject* maybe_map_unchecked = object->map()->CopyDropDescriptors(); | |
| 1995 if (!maybe_map_unchecked->ToObject(&map_unchecked)) { | |
| 1996 return maybe_map_unchecked; | |
| 1997 } | |
| 1998 } | |
| 1999 Map* new_map = Map::cast(map_unchecked); | |
| 2000 new_map->set_instance_descriptors(new_descriptors); | |
| 2001 object->set_map(new_map); | |
| 2002 } else { // Dictionary properties. | |
| 2003 // Directly manipulate the property details. | |
| 2004 int entry = object->property_dictionary()->FindEntry(name); | |
|
Rico
2011/07/25 13:05:42
assert that entry != kNotFound
Jakob Kummerow
2011/07/25 14:57:05
Done.
| |
| 2005 PropertyDetails details = object->property_dictionary()->DetailsAt(entry); | |
| 2006 PropertyDetails new_details( | |
| 2007 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | |
| 2008 details.type(), details.index()); | |
|
Rico
2011/07/25 13:05:42
nit, put last argument on seperate line
Jakob Kummerow
2011/07/25 14:57:05
Done.
| |
| 2009 object->property_dictionary()->DetailsAtPut(entry, new_details); | |
| 2010 } | |
| 2011 return object; | |
| 2012 } | |
| 2013 | |
| 2014 | |
| 1963 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2015 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
| 1964 NoHandleAllocation ha; | 2016 NoHandleAllocation ha; |
| 1965 ASSERT(args.length() == 1); | 2017 ASSERT(args.length() == 1); |
| 1966 | 2018 |
| 1967 CONVERT_CHECKED(JSFunction, f, args[0]); | 2019 CONVERT_CHECKED(JSFunction, f, args[0]); |
| 1968 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() | 2020 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() |
| 1969 : isolate->heap()->false_value(); | 2021 : isolate->heap()->false_value(); |
| 1970 } | 2022 } |
| 1971 | 2023 |
| 1972 | 2024 |
| (...skipping 10697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12670 } else { | 12722 } else { |
| 12671 // Handle last resort GC and make sure to allow future allocations | 12723 // Handle last resort GC and make sure to allow future allocations |
| 12672 // to grow the heap without causing GCs (if possible). | 12724 // to grow the heap without causing GCs (if possible). |
| 12673 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12725 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 12674 isolate->heap()->CollectAllGarbage(false); | 12726 isolate->heap()->CollectAllGarbage(false); |
| 12675 } | 12727 } |
| 12676 } | 12728 } |
| 12677 | 12729 |
| 12678 | 12730 |
| 12679 } } // namespace v8::internal | 12731 } } // namespace v8::internal |
| OLD | NEW |