OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 shared->DontAdaptArguments(); | 1686 shared->DontAdaptArguments(); |
1687 shared->set_length(2); | 1687 shared->set_length(2); |
1688 | 1688 |
1689 { | 1689 { |
1690 // RegExp.prototype setup. | 1690 // RegExp.prototype setup. |
1691 | 1691 |
1692 // Install the "constructor" property on the {prototype}. | 1692 // Install the "constructor" property on the {prototype}. |
1693 JSObject::AddProperty(prototype, factory->constructor_string(), | 1693 JSObject::AddProperty(prototype, factory->constructor_string(), |
1694 regexp_fun, DONT_ENUM); | 1694 regexp_fun, DONT_ENUM); |
1695 | 1695 |
1696 SimpleInstallFunction(prototype, "exec", Builtins::kRegExpPrototypeExec, | 1696 { |
1697 1, true, DONT_ENUM); | 1697 Handle<JSFunction> fun = SimpleInstallFunction( |
| 1698 prototype, "exec", Builtins::kRegExpPrototypeExec, 1, true, |
| 1699 DONT_ENUM); |
| 1700 native_context()->set_regexp_exec_function(*fun); |
| 1701 } |
1698 | 1702 |
1699 SimpleInstallGetter(prototype, factory->flags_string(), | 1703 SimpleInstallGetter(prototype, factory->flags_string(), |
1700 Builtins::kRegExpPrototypeFlagsGetter, true); | 1704 Builtins::kRegExpPrototypeFlagsGetter, true); |
1701 SimpleInstallGetter(prototype, factory->global_string(), | 1705 SimpleInstallGetter(prototype, factory->global_string(), |
1702 Builtins::kRegExpPrototypeGlobalGetter, true); | 1706 Builtins::kRegExpPrototypeGlobalGetter, true); |
1703 SimpleInstallGetter(prototype, factory->ignoreCase_string(), | 1707 SimpleInstallGetter(prototype, factory->ignoreCase_string(), |
1704 Builtins::kRegExpPrototypeIgnoreCaseGetter, true); | 1708 Builtins::kRegExpPrototypeIgnoreCaseGetter, true); |
1705 SimpleInstallGetter(prototype, factory->multiline_string(), | 1709 SimpleInstallGetter(prototype, factory->multiline_string(), |
1706 Builtins::kRegExpPrototypeMultilineGetter, true); | 1710 Builtins::kRegExpPrototypeMultilineGetter, true); |
1707 SimpleInstallGetter(prototype, factory->source_string(), | 1711 SimpleInstallGetter(prototype, factory->source_string(), |
1708 Builtins::kRegExpPrototypeSourceGetter, false); | 1712 Builtins::kRegExpPrototypeSourceGetter, false); |
1709 SimpleInstallGetter(prototype, factory->sticky_string(), | 1713 SimpleInstallGetter(prototype, factory->sticky_string(), |
1710 Builtins::kRegExpPrototypeStickyGetter, true); | 1714 Builtins::kRegExpPrototypeStickyGetter, true); |
1711 SimpleInstallGetter(prototype, factory->unicode_string(), | 1715 SimpleInstallGetter(prototype, factory->unicode_string(), |
1712 Builtins::kRegExpPrototypeUnicodeGetter, true); | 1716 Builtins::kRegExpPrototypeUnicodeGetter, true); |
1713 | 1717 |
1714 SimpleInstallFunction(prototype, "compile", | 1718 SimpleInstallFunction(prototype, "compile", |
1715 Builtins::kRegExpPrototypeCompile, 2, false, | 1719 Builtins::kRegExpPrototypeCompile, 2, false, |
1716 DONT_ENUM); | 1720 DONT_ENUM); |
1717 SimpleInstallFunction(prototype, factory->toString_string(), | 1721 SimpleInstallFunction(prototype, factory->toString_string(), |
1718 Builtins::kRegExpPrototypeToString, 0, false, | 1722 Builtins::kRegExpPrototypeToString, 0, false, |
1719 DONT_ENUM); | 1723 DONT_ENUM); |
| 1724 SimpleInstallFunction(prototype, "test", Builtins::kRegExpPrototypeTest, |
| 1725 1, false, DONT_ENUM); |
| 1726 |
| 1727 { |
| 1728 Handle<JSFunction> fun = SimpleCreateFunction( |
| 1729 isolate, factory->InternalizeUtf8String("[Symbol.match]"), |
| 1730 Builtins::kRegExpPrototypeMatch, 1, false); |
| 1731 InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM); |
| 1732 } |
| 1733 |
| 1734 { |
| 1735 Handle<JSFunction> fun = SimpleCreateFunction( |
| 1736 isolate, factory->InternalizeUtf8String("[Symbol.search]"), |
| 1737 Builtins::kRegExpPrototypeSearch, 1, false); |
| 1738 InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM); |
| 1739 } |
1720 } | 1740 } |
1721 | 1741 |
1722 { | 1742 { |
1723 // RegExp getters and setters. | 1743 // RegExp getters and setters. |
1724 | 1744 |
1725 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE. | 1745 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE. |
1726 // However, that currently breaks layout test expectations. Note that | 1746 // However, that currently breaks layout test expectations. Note that |
1727 // Firefox sets a couple of these as enumerable. | 1747 // Firefox sets a couple of these as enumerable. |
1728 // On the other hand, installing attributes as DONT_ENUM matches the draft | 1748 // On the other hand, installing attributes as DONT_ENUM matches the draft |
1729 // specification at | 1749 // specification at |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 DCHECK(regexp_fun->has_initial_map()); | 1816 DCHECK(regexp_fun->has_initial_map()); |
1797 Handle<Map> initial_map(regexp_fun->initial_map()); | 1817 Handle<Map> initial_map(regexp_fun->initial_map()); |
1798 | 1818 |
1799 DCHECK_EQ(0, initial_map->GetInObjectProperties()); | 1819 DCHECK_EQ(0, initial_map->GetInObjectProperties()); |
1800 | 1820 |
1801 Map::EnsureDescriptorSlack(initial_map, 1); | 1821 Map::EnsureDescriptorSlack(initial_map, 1); |
1802 | 1822 |
1803 // ECMA-262, section 15.10.7.5. | 1823 // ECMA-262, section 15.10.7.5. |
1804 PropertyAttributes writable = | 1824 PropertyAttributes writable = |
1805 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 1825 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
1806 DataDescriptor field(factory->last_index_string(), | 1826 DataDescriptor field(factory->lastIndex_string(), |
1807 JSRegExp::kLastIndexFieldIndex, writable, | 1827 JSRegExp::kLastIndexFieldIndex, writable, |
1808 Representation::Tagged()); | 1828 Representation::Tagged()); |
1809 initial_map->AppendDescriptor(&field); | 1829 initial_map->AppendDescriptor(&field); |
1810 | 1830 |
1811 static const int num_fields = JSRegExp::kInObjectFieldCount; | 1831 static const int num_fields = JSRegExp::kInObjectFieldCount; |
1812 initial_map->SetInObjectProperties(num_fields); | 1832 initial_map->SetInObjectProperties(num_fields); |
1813 initial_map->set_unused_property_fields(0); | 1833 initial_map->set_unused_property_fields(0); |
1814 initial_map->set_instance_size(initial_map->instance_size() + | 1834 initial_map->set_instance_size(initial_map->instance_size() + |
1815 num_fields * kPointerSize); | 1835 num_fields * kPointerSize); |
1816 } | 1836 } |
(...skipping 2515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4332 } | 4352 } |
4333 | 4353 |
4334 | 4354 |
4335 // Called when the top-level V8 mutex is destroyed. | 4355 // Called when the top-level V8 mutex is destroyed. |
4336 void Bootstrapper::FreeThreadResources() { | 4356 void Bootstrapper::FreeThreadResources() { |
4337 DCHECK(!IsActive()); | 4357 DCHECK(!IsActive()); |
4338 } | 4358 } |
4339 | 4359 |
4340 } // namespace internal | 4360 } // namespace internal |
4341 } // namespace v8 | 4361 } // namespace v8 |
OLD | NEW |