OLD | NEW |
1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 bool found_it = false; | 479 bool found_it = false; |
480 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); | 480 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); |
481 if (!found_it) return heap->undefined_value(); | 481 if (!found_it) return heap->undefined_value(); |
482 if (!function->should_have_prototype()) { | 482 if (!function->should_have_prototype()) { |
483 // Since we hit this accessor, object will have no prototype property. | 483 // Since we hit this accessor, object will have no prototype property. |
484 return object->SetLocalPropertyIgnoreAttributes(heap->prototype_symbol(), | 484 return object->SetLocalPropertyIgnoreAttributes(heap->prototype_symbol(), |
485 value, | 485 value, |
486 NONE); | 486 NONE); |
487 } | 487 } |
488 | 488 |
489 if (function->has_initial_map()) { | |
490 // If the function has allocated the initial map | |
491 // replace it with a copy containing the new prototype. | |
492 Object* new_map; | |
493 { MaybeObject* maybe_new_map = | |
494 function->initial_map()->CopyDropTransitions(); | |
495 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | |
496 } | |
497 function->set_initial_map(Map::cast(new_map)); | |
498 } | |
499 Object* prototype; | 489 Object* prototype; |
500 { MaybeObject* maybe_prototype = function->SetPrototype(value); | 490 { MaybeObject* maybe_prototype = function->SetPrototype(value); |
501 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; | 491 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; |
502 } | 492 } |
503 ASSERT(function->prototype() == value); | 493 ASSERT(function->prototype() == value); |
504 return function; | 494 return function; |
505 } | 495 } |
506 | 496 |
507 | 497 |
508 const AccessorDescriptor Accessors::FunctionPrototype = { | 498 const AccessorDescriptor Accessors::FunctionPrototype = { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 793 } |
804 | 794 |
805 | 795 |
806 const AccessorDescriptor Accessors::ObjectPrototype = { | 796 const AccessorDescriptor Accessors::ObjectPrototype = { |
807 ObjectGetPrototype, | 797 ObjectGetPrototype, |
808 ObjectSetPrototype, | 798 ObjectSetPrototype, |
809 0 | 799 0 |
810 }; | 800 }; |
811 | 801 |
812 } } // namespace v8::internal | 802 } } // namespace v8::internal |
OLD | NEW |