OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 | 732 |
733 { // --- arguments_boilerplate_ | 733 { // --- arguments_boilerplate_ |
734 // Make sure we can recognize argument objects at runtime. | 734 // Make sure we can recognize argument objects at runtime. |
735 // This is done by introducing an anonymous function with | 735 // This is done by introducing an anonymous function with |
736 // class_name equals 'Arguments'. | 736 // class_name equals 'Arguments'. |
737 Handle<String> symbol = Factory::LookupAsciiSymbol("Arguments"); | 737 Handle<String> symbol = Factory::LookupAsciiSymbol("Arguments"); |
738 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); | 738 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); |
739 Handle<JSObject> prototype = | 739 Handle<JSObject> prototype = |
740 Handle<JSObject>( | 740 Handle<JSObject>( |
741 JSObject::cast(global_context()->object_function()->prototype())); | 741 JSObject::cast(global_context()->object_function()->prototype())); |
| 742 |
742 Handle<JSFunction> function = | 743 Handle<JSFunction> function = |
743 Factory::NewFunctionWithPrototype(symbol, JS_OBJECT_TYPE, | 744 Factory::NewFunctionWithPrototype(symbol, |
744 JSObject::kHeaderSize, prototype, | 745 JS_OBJECT_TYPE, |
745 code, true); | 746 JSObject::kHeaderSize, |
| 747 prototype, |
| 748 code, |
| 749 false); |
| 750 ASSERT(!function->has_initial_map()); |
746 function->shared()->set_instance_class_name(*symbol); | 751 function->shared()->set_instance_class_name(*symbol); |
747 | 752 function->shared()->set_expected_nof_properties(2); |
748 Handle<JSObject> result = Factory::NewJSObject(function); | 753 Handle<JSObject> result = Factory::NewJSObject(function); |
749 | 754 |
750 global_context()->set_arguments_boilerplate(*result); | 755 global_context()->set_arguments_boilerplate(*result); |
751 // Note: callee must be added as the first property and | 756 // Note: callee must be added as the first property and |
752 // length must be added as the second property. | 757 // length must be added as the second property. |
753 SetProperty(result, Factory::callee_symbol(), Factory::undefined_value(), | 758 SetProperty(result, Factory::callee_symbol(), |
| 759 Factory::undefined_value(), |
754 DONT_ENUM); | 760 DONT_ENUM); |
755 SetProperty(result, Factory::length_symbol(), Factory::undefined_value(), | 761 SetProperty(result, Factory::length_symbol(), |
| 762 Factory::undefined_value(), |
756 DONT_ENUM); | 763 DONT_ENUM); |
757 | 764 |
| 765 #ifdef DEBUG |
| 766 LookupResult lookup; |
| 767 result->LocalLookup(Heap::callee_symbol(), &lookup); |
| 768 ASSERT(lookup.IsValid() && (lookup.type() == FIELD)); |
| 769 ASSERT(lookup.GetFieldIndex() == Heap::arguments_callee_index); |
| 770 |
| 771 result->LocalLookup(Heap::length_symbol(), &lookup); |
| 772 ASSERT(lookup.IsValid() && (lookup.type() == FIELD)); |
| 773 ASSERT(lookup.GetFieldIndex() == Heap::arguments_length_index); |
| 774 |
| 775 ASSERT(result->map()->inobject_properties() > Heap::arguments_callee_index); |
| 776 ASSERT(result->map()->inobject_properties() > Heap::arguments_length_index); |
| 777 |
758 // Check the state of the object. | 778 // Check the state of the object. |
759 ASSERT(result->HasFastProperties()); | 779 ASSERT(result->HasFastProperties()); |
760 ASSERT(result->HasFastElements()); | 780 ASSERT(result->HasFastElements()); |
| 781 #endif |
761 } | 782 } |
762 | 783 |
763 { // --- context extension | 784 { // --- context extension |
764 // Create a function for the context extension objects. | 785 // Create a function for the context extension objects. |
765 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); | 786 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); |
766 Handle<JSFunction> context_extension_fun = | 787 Handle<JSFunction> context_extension_fun = |
767 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, | 788 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, |
768 JSObject::kHeaderSize, code, true); | 789 JSObject::kHeaderSize, code, true); |
769 | 790 |
770 Handle<String> name = Factory::LookupAsciiSymbol("context_extension"); | 791 Handle<String> name = Factory::LookupAsciiSymbol("context_extension"); |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 if (!ConfigureGlobalObjects(global_template)) return; | 1448 if (!ConfigureGlobalObjects(global_template)) return; |
1428 | 1449 |
1429 if (!InstallExtensions(extensions)) return; | 1450 if (!InstallExtensions(extensions)) return; |
1430 | 1451 |
1431 if (!InstallSpecialObjects()) return; | 1452 if (!InstallSpecialObjects()) return; |
1432 | 1453 |
1433 result_ = global_context_; | 1454 result_ = global_context_; |
1434 } | 1455 } |
1435 | 1456 |
1436 } } // namespace v8::internal | 1457 } } // namespace v8::internal |
OLD | NEW |