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