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