OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 int instance_size, | 566 int instance_size, |
567 ElementsKind elements_kind) { | 567 ElementsKind elements_kind) { |
568 CALL_HEAP_FUNCTION( | 568 CALL_HEAP_FUNCTION( |
569 isolate(), | 569 isolate(), |
570 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), | 570 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), |
571 Map); | 571 Map); |
572 } | 572 } |
573 | 573 |
574 | 574 |
575 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { | 575 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
576 CALL_HEAP_FUNCTION( | 576 // Make sure to use globals from the function's context, since the function |
577 isolate(), | 577 // can be from a different context. |
578 isolate()->heap()->AllocateFunctionPrototype(*function), | 578 Handle<Context> native_context(function->context()->native_context()); |
579 JSObject); | 579 Handle<Map> new_map; |
| 580 if (function->shared()->is_generator()) { |
| 581 // Generator prototypes can share maps since they don't have "constructor" |
| 582 // properties. |
| 583 new_map = handle(native_context->generator_object_prototype_map()); |
| 584 } else { |
| 585 // Each function prototype gets a fresh map to avoid unwanted sharing of |
| 586 // maps between prototypes of different constructors. |
| 587 Handle<JSFunction> object_function(native_context->object_function()); |
| 588 ASSERT(object_function->has_initial_map()); |
| 589 new_map = Map::Copy(handle(object_function->initial_map())); |
| 590 } |
| 591 |
| 592 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); |
| 593 |
| 594 if (!function->shared()->is_generator()) { |
| 595 JSObject::SetLocalPropertyIgnoreAttributes(prototype, |
| 596 constructor_string(), |
| 597 function, |
| 598 DONT_ENUM); |
| 599 } |
| 600 |
| 601 return prototype; |
580 } | 602 } |
581 | 603 |
582 | 604 |
583 Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) { | 605 Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) { |
584 CALL_HEAP_FUNCTION( | 606 CALL_HEAP_FUNCTION( |
585 isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map); | 607 isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map); |
586 } | 608 } |
587 | 609 |
588 | 610 |
589 Handle<Map> Factory::CopyMap(Handle<Map> src, | 611 Handle<Map> Factory::CopyMap(Handle<Map> src, |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 return Handle<Object>::null(); | 1775 return Handle<Object>::null(); |
1754 } | 1776 } |
1755 | 1777 |
1756 | 1778 |
1757 Handle<Object> Factory::ToBoolean(bool value) { | 1779 Handle<Object> Factory::ToBoolean(bool value) { |
1758 return value ? true_value() : false_value(); | 1780 return value ? true_value() : false_value(); |
1759 } | 1781 } |
1760 | 1782 |
1761 | 1783 |
1762 } } // namespace v8::internal | 1784 } } // namespace v8::internal |
OLD | NEW |