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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
716 global_context()->set_date_function(*date_fun); | 716 global_context()->set_date_function(*date_fun); |
717 } | 717 } |
718 | 718 |
719 | 719 |
720 { // -- R e g E x p | 720 { // -- R e g E x p |
721 // Builtin functions for RegExp.prototype. | 721 // Builtin functions for RegExp.prototype. |
722 Handle<JSFunction> regexp_fun = | 722 Handle<JSFunction> regexp_fun = |
723 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 723 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
724 Top::initial_object_prototype(), Builtins::Illegal, | 724 Top::initial_object_prototype(), Builtins::Illegal, |
725 true); | 725 true); |
726 global_context()->set_regexp_function(*regexp_fun); | |
726 | 727 |
727 global_context()->set_regexp_function(*regexp_fun); | 728 ASSERT(regexp_fun->has_initial_map()); |
729 Handle<Map> initial_map(regexp_fun->initial_map()); | |
730 | |
731 ASSERT_EQ(0, initial_map->inobject_properties()); | |
732 | |
733 Handle<DescriptorArray> descriptors = Factory::NewDescriptorArray(5); | |
734 PropertyAttributes final = | |
735 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | |
736 { | |
737 // ECMA-262, section 15.10.7.1. | |
738 FieldDescriptor field(Heap::source_symbol(), | |
739 JSRegExp::kSourceFieldIndex, | |
740 final, | |
741 0); | |
742 descriptors->Set(0, &field); | |
743 } | |
744 { | |
745 // ECMA-262, section 15.10.7.2. | |
746 FieldDescriptor field(Heap::global_symbol(), | |
747 JSRegExp::kGlobalFieldIndex, | |
748 final, | |
749 1); | |
750 descriptors->Set(1, &field); | |
751 } | |
752 { | |
753 // ECMA-262, section 15.10.7.3. | |
754 FieldDescriptor field(Heap::ignore_case_symbol(), | |
755 JSRegExp::kIgnoreCaseFieldIndex, | |
756 final, | |
757 2); | |
758 descriptors->Set(2, &field); | |
759 } | |
760 { | |
761 // ECMA-262, section 15.10.7.4. | |
762 FieldDescriptor field(Heap::multiline_symbol(), | |
763 JSRegExp::kMultilineFieldIndex, | |
764 final, | |
765 3); | |
Erik Corry
2010/03/26 13:51:34
You already made a constant for this '3'.
Lasse Reichstein
2010/03/26 14:19:09
Actually, not. This "3" is the enumeration index,
| |
766 descriptors->Set(3, &field); | |
767 } | |
768 { | |
769 // ECMA-262, section 15.10.7.5. | |
770 PropertyAttributes writable = | |
771 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | |
772 FieldDescriptor field(Heap::last_index_symbol(), | |
773 JSRegExp::kLastIndexFieldIndex, | |
774 writable, | |
775 4); | |
776 descriptors->Set(4, &field); | |
777 } | |
778 descriptors->SetNextEnumerationIndex(5); | |
779 descriptors->Sort(); | |
780 | |
781 initial_map->set_inobject_properties(5); | |
782 initial_map->set_pre_allocated_property_fields(5); | |
783 initial_map->set_unused_property_fields(0); | |
784 initial_map->set_instance_size( | |
785 initial_map->instance_size() + 5 * kPointerSize); | |
786 initial_map->set_instance_descriptors(*descriptors); | |
728 } | 787 } |
729 | 788 |
730 { // -- J S O N | 789 { // -- J S O N |
731 Handle<String> name = Factory::NewStringFromAscii(CStrVector("JSON")); | 790 Handle<String> name = Factory::NewStringFromAscii(CStrVector("JSON")); |
732 Handle<JSFunction> cons = Factory::NewFunction( | 791 Handle<JSFunction> cons = Factory::NewFunction( |
733 name, | 792 name, |
734 Factory::the_hole_value()); | 793 Factory::the_hole_value()); |
735 cons->SetInstancePrototype(global_context()->initial_object_prototype()); | 794 cons->SetInstancePrototype(global_context()->initial_object_prototype()); |
736 cons->SetInstanceClassName(*name); | 795 cons->SetInstanceClassName(*name); |
737 Handle<JSObject> json_object = Factory::NewJSObject(cons, TENURED); | 796 Handle<JSObject> json_object = Factory::NewJSObject(cons, TENURED); |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 } | 1658 } |
1600 | 1659 |
1601 | 1660 |
1602 // Restore statics that are thread local. | 1661 // Restore statics that are thread local. |
1603 char* BootstrapperActive::RestoreState(char* from) { | 1662 char* BootstrapperActive::RestoreState(char* from) { |
1604 nesting_ = *reinterpret_cast<int*>(from); | 1663 nesting_ = *reinterpret_cast<int*>(from); |
1605 return from + sizeof(nesting_); | 1664 return from + sizeof(nesting_); |
1606 } | 1665 } |
1607 | 1666 |
1608 } } // namespace v8::internal | 1667 } } // namespace v8::internal |
OLD | NEW |