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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 // Set the length for the function to satisfy ECMA-262. | 1642 // Set the length for the function to satisfy ECMA-262. |
1643 to_primitive->shared()->set_length(1); | 1643 to_primitive->shared()->set_length(1); |
1644 } | 1644 } |
1645 | 1645 |
1646 { // -- R e g E x p | 1646 { // -- R e g E x p |
1647 // Builtin functions for RegExp.prototype. | 1647 // Builtin functions for RegExp.prototype. |
1648 Handle<JSObject> prototype = | 1648 Handle<JSObject> prototype = |
1649 factory->NewJSObject(isolate->object_function(), TENURED); | 1649 factory->NewJSObject(isolate->object_function(), TENURED); |
1650 Handle<JSFunction> regexp_fun = | 1650 Handle<JSFunction> regexp_fun = |
1651 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 1651 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
1652 prototype, Builtins::kIllegal); | 1652 prototype, Builtins::kRegExpConstructor); |
1653 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, | 1653 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, |
1654 Context::REGEXP_FUNCTION_INDEX); | 1654 Context::REGEXP_FUNCTION_INDEX); |
1655 regexp_fun->shared()->SetConstructStub( | 1655 |
1656 *isolate->builtins()->JSBuiltinsConstructStub()); | 1656 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate); |
| 1657 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor()); |
| 1658 shared->set_instance_class_name(isolate->heap()->RegExp_string()); |
| 1659 shared->DontAdaptArguments(); |
| 1660 shared->set_length(2); |
| 1661 |
| 1662 // RegExp.prototype setup. |
| 1663 |
| 1664 // Install the "constructor" property on the {prototype}. |
| 1665 JSObject::AddProperty(prototype, factory->constructor_string(), regexp_fun, |
| 1666 DONT_ENUM); |
| 1667 |
| 1668 SimpleInstallFunction(prototype, "exec", Builtins::kRegExpPrototypeExec, 1, |
| 1669 true, DONT_ENUM); |
1657 | 1670 |
1658 DCHECK(regexp_fun->has_initial_map()); | 1671 DCHECK(regexp_fun->has_initial_map()); |
1659 Handle<Map> initial_map(regexp_fun->initial_map()); | 1672 Handle<Map> initial_map(regexp_fun->initial_map()); |
1660 | 1673 |
1661 DCHECK_EQ(0, initial_map->GetInObjectProperties()); | 1674 DCHECK_EQ(0, initial_map->GetInObjectProperties()); |
1662 | 1675 |
1663 Map::EnsureDescriptorSlack(initial_map, 1); | 1676 Map::EnsureDescriptorSlack(initial_map, 1); |
1664 | 1677 |
1665 // ECMA-262, section 15.10.7.5. | 1678 // ECMA-262, section 15.10.7.5. |
1666 PropertyAttributes writable = | 1679 PropertyAttributes writable = |
1667 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 1680 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
1668 DataDescriptor field(factory->last_index_string(), | 1681 DataDescriptor field(factory->last_index_string(), |
1669 JSRegExp::kLastIndexFieldIndex, writable, | 1682 JSRegExp::kLastIndexFieldIndex, writable, |
1670 Representation::Tagged()); | 1683 Representation::Tagged()); |
1671 initial_map->AppendDescriptor(&field); | 1684 initial_map->AppendDescriptor(&field); |
1672 | 1685 |
1673 static const int num_fields = JSRegExp::kInObjectFieldCount; | 1686 static const int num_fields = JSRegExp::kInObjectFieldCount; |
1674 initial_map->SetInObjectProperties(num_fields); | 1687 initial_map->SetInObjectProperties(num_fields); |
1675 initial_map->set_unused_property_fields(0); | 1688 initial_map->set_unused_property_fields(0); |
1676 initial_map->set_instance_size(initial_map->instance_size() + | 1689 initial_map->set_instance_size(initial_map->instance_size() + |
1677 num_fields * kPointerSize); | 1690 num_fields * kPointerSize); |
1678 | |
1679 // RegExp.prototype setup. | |
1680 | |
1681 // Install the "constructor" property on the {prototype}. | |
1682 JSObject::AddProperty(prototype, factory->constructor_string(), regexp_fun, | |
1683 DONT_ENUM); | |
1684 | |
1685 SimpleInstallFunction(prototype, "exec", Builtins::kRegExpPrototypeExec, 1, | |
1686 true, DONT_ENUM); | |
1687 } | 1691 } |
1688 | 1692 |
1689 { // -- E r r o r | 1693 { // -- E r r o r |
1690 InstallError(isolate, global, factory->Error_string(), | 1694 InstallError(isolate, global, factory->Error_string(), |
1691 Context::ERROR_FUNCTION_INDEX); | 1695 Context::ERROR_FUNCTION_INDEX); |
1692 InstallMakeError(isolate, isolate->builtins()->MakeError(), | 1696 InstallMakeError(isolate, isolate->builtins()->MakeError(), |
1693 Context::MAKE_ERROR_INDEX); | 1697 Context::MAKE_ERROR_INDEX); |
1694 } | 1698 } |
1695 | 1699 |
1696 { // -- E v a l E r r o r | 1700 { // -- E v a l E r r o r |
(...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4203 } | 4207 } |
4204 | 4208 |
4205 | 4209 |
4206 // Called when the top-level V8 mutex is destroyed. | 4210 // Called when the top-level V8 mutex is destroyed. |
4207 void Bootstrapper::FreeThreadResources() { | 4211 void Bootstrapper::FreeThreadResources() { |
4208 DCHECK(!IsActive()); | 4212 DCHECK(!IsActive()); |
4209 } | 4213 } |
4210 | 4214 |
4211 } // namespace internal | 4215 } // namespace internal |
4212 } // namespace v8 | 4216 } // namespace v8 |
OLD | NEW |