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 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 shared->DontAdaptArguments(); | 1695 shared->DontAdaptArguments(); |
1696 shared->set_length(2); | 1696 shared->set_length(2); |
1697 | 1697 |
1698 { | 1698 { |
1699 // RegExp.prototype setup. | 1699 // RegExp.prototype setup. |
1700 | 1700 |
1701 // Install the "constructor" property on the {prototype}. | 1701 // Install the "constructor" property on the {prototype}. |
1702 JSObject::AddProperty(prototype, factory->constructor_string(), | 1702 JSObject::AddProperty(prototype, factory->constructor_string(), |
1703 regexp_fun, DONT_ENUM); | 1703 regexp_fun, DONT_ENUM); |
1704 | 1704 |
1705 SimpleInstallFunction(prototype, "exec", Builtins::kRegExpPrototypeExec, | 1705 { |
1706 1, true, DONT_ENUM); | 1706 Handle<JSFunction> fun = SimpleInstallFunction( |
| 1707 prototype, "exec", Builtins::kRegExpPrototypeExec, 1, true, |
| 1708 DONT_ENUM); |
| 1709 native_context()->set_regexp_exec_function(*fun); |
| 1710 } |
1707 | 1711 |
1708 SimpleInstallGetter(prototype, factory->flags_string(), | 1712 SimpleInstallGetter(prototype, factory->flags_string(), |
1709 Builtins::kRegExpPrototypeFlagsGetter, true); | 1713 Builtins::kRegExpPrototypeFlagsGetter, true); |
1710 SimpleInstallGetter(prototype, factory->global_string(), | 1714 SimpleInstallGetter(prototype, factory->global_string(), |
1711 Builtins::kRegExpPrototypeGlobalGetter, true); | 1715 Builtins::kRegExpPrototypeGlobalGetter, true); |
1712 SimpleInstallGetter(prototype, factory->ignoreCase_string(), | 1716 SimpleInstallGetter(prototype, factory->ignoreCase_string(), |
1713 Builtins::kRegExpPrototypeIgnoreCaseGetter, true); | 1717 Builtins::kRegExpPrototypeIgnoreCaseGetter, true); |
1714 SimpleInstallGetter(prototype, factory->multiline_string(), | 1718 SimpleInstallGetter(prototype, factory->multiline_string(), |
1715 Builtins::kRegExpPrototypeMultilineGetter, true); | 1719 Builtins::kRegExpPrototypeMultilineGetter, true); |
1716 SimpleInstallGetter(prototype, factory->source_string(), | 1720 SimpleInstallGetter(prototype, factory->source_string(), |
1717 Builtins::kRegExpPrototypeSourceGetter, false); | 1721 Builtins::kRegExpPrototypeSourceGetter, false); |
1718 SimpleInstallGetter(prototype, factory->sticky_string(), | 1722 SimpleInstallGetter(prototype, factory->sticky_string(), |
1719 Builtins::kRegExpPrototypeStickyGetter, true); | 1723 Builtins::kRegExpPrototypeStickyGetter, true); |
1720 SimpleInstallGetter(prototype, factory->unicode_string(), | 1724 SimpleInstallGetter(prototype, factory->unicode_string(), |
1721 Builtins::kRegExpPrototypeUnicodeGetter, true); | 1725 Builtins::kRegExpPrototypeUnicodeGetter, true); |
1722 | 1726 |
1723 SimpleInstallFunction(prototype, "compile", | 1727 SimpleInstallFunction(prototype, "compile", |
1724 Builtins::kRegExpPrototypeCompile, 2, false, | 1728 Builtins::kRegExpPrototypeCompile, 2, false, |
1725 DONT_ENUM); | 1729 DONT_ENUM); |
1726 SimpleInstallFunction(prototype, factory->toString_string(), | 1730 SimpleInstallFunction(prototype, factory->toString_string(), |
1727 Builtins::kRegExpPrototypeToString, 0, false, | 1731 Builtins::kRegExpPrototypeToString, 0, false, |
1728 DONT_ENUM); | 1732 DONT_ENUM); |
| 1733 SimpleInstallFunction(prototype, "test", Builtins::kRegExpPrototypeTest, |
| 1734 1, false, DONT_ENUM); |
| 1735 |
| 1736 { |
| 1737 Handle<JSFunction> fun = SimpleCreateFunction( |
| 1738 isolate, factory->InternalizeUtf8String("[Symbol.match]"), |
| 1739 Builtins::kRegExpPrototypeMatch, 1, false); |
| 1740 InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM); |
| 1741 } |
| 1742 |
| 1743 { |
| 1744 Handle<JSFunction> fun = SimpleCreateFunction( |
| 1745 isolate, factory->InternalizeUtf8String("[Symbol.search]"), |
| 1746 Builtins::kRegExpPrototypeSearch, 1, false); |
| 1747 InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM); |
| 1748 } |
1729 } | 1749 } |
1730 | 1750 |
1731 { | 1751 { |
1732 // RegExp getters and setters. | 1752 // RegExp getters and setters. |
1733 | 1753 |
1734 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE. | 1754 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE. |
1735 // However, that currently breaks layout test expectations. Note that | 1755 // However, that currently breaks layout test expectations. Note that |
1736 // Firefox sets a couple of these as enumerable. | 1756 // Firefox sets a couple of these as enumerable. |
1737 // On the other hand, installing attributes as DONT_ENUM matches the draft | 1757 // On the other hand, installing attributes as DONT_ENUM matches the draft |
1738 // specification at | 1758 // specification at |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 DCHECK(regexp_fun->has_initial_map()); | 1825 DCHECK(regexp_fun->has_initial_map()); |
1806 Handle<Map> initial_map(regexp_fun->initial_map()); | 1826 Handle<Map> initial_map(regexp_fun->initial_map()); |
1807 | 1827 |
1808 DCHECK_EQ(0, initial_map->GetInObjectProperties()); | 1828 DCHECK_EQ(0, initial_map->GetInObjectProperties()); |
1809 | 1829 |
1810 Map::EnsureDescriptorSlack(initial_map, 1); | 1830 Map::EnsureDescriptorSlack(initial_map, 1); |
1811 | 1831 |
1812 // ECMA-262, section 15.10.7.5. | 1832 // ECMA-262, section 15.10.7.5. |
1813 PropertyAttributes writable = | 1833 PropertyAttributes writable = |
1814 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 1834 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
1815 DataDescriptor field(factory->last_index_string(), | 1835 DataDescriptor field(factory->lastIndex_string(), |
1816 JSRegExp::kLastIndexFieldIndex, writable, | 1836 JSRegExp::kLastIndexFieldIndex, writable, |
1817 Representation::Tagged()); | 1837 Representation::Tagged()); |
1818 initial_map->AppendDescriptor(&field); | 1838 initial_map->AppendDescriptor(&field); |
1819 | 1839 |
1820 static const int num_fields = JSRegExp::kInObjectFieldCount; | 1840 static const int num_fields = JSRegExp::kInObjectFieldCount; |
1821 initial_map->SetInObjectProperties(num_fields); | 1841 initial_map->SetInObjectProperties(num_fields); |
1822 initial_map->set_unused_property_fields(0); | 1842 initial_map->set_unused_property_fields(0); |
1823 initial_map->set_instance_size(initial_map->instance_size() + | 1843 initial_map->set_instance_size(initial_map->instance_size() + |
1824 num_fields * kPointerSize); | 1844 num_fields * kPointerSize); |
1825 } | 1845 } |
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4360 } | 4380 } |
4361 | 4381 |
4362 | 4382 |
4363 // Called when the top-level V8 mutex is destroyed. | 4383 // Called when the top-level V8 mutex is destroyed. |
4364 void Bootstrapper::FreeThreadResources() { | 4384 void Bootstrapper::FreeThreadResources() { |
4365 DCHECK(!IsActive()); | 4385 DCHECK(!IsActive()); |
4366 } | 4386 } |
4367 | 4387 |
4368 } // namespace internal | 4388 } // namespace internal |
4369 } // namespace v8 | 4389 } // namespace v8 |
OLD | NEW |