Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: src/bootstrapper.cc

Issue 2384613004: [regexp] Port RegExpConstructor to C++ (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | src/builtins/builtins-regexp.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 // Set the length for the function to satisfy ECMA-262. 1634 // Set the length for the function to satisfy ECMA-262.
1635 to_primitive->shared()->set_length(1); 1635 to_primitive->shared()->set_length(1);
1636 } 1636 }
1637 1637
1638 { // -- R e g E x p 1638 { // -- R e g E x p
1639 // Builtin functions for RegExp.prototype. 1639 // Builtin functions for RegExp.prototype.
1640 Handle<JSObject> prototype = 1640 Handle<JSObject> prototype =
1641 factory->NewJSObject(isolate->object_function(), TENURED); 1641 factory->NewJSObject(isolate->object_function(), TENURED);
1642 Handle<JSFunction> regexp_fun = 1642 Handle<JSFunction> regexp_fun =
1643 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 1643 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
1644 prototype, Builtins::kIllegal); 1644 prototype, Builtins::kRegExpConstructor);
1645 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, 1645 InstallWithIntrinsicDefaultProto(isolate, regexp_fun,
1646 Context::REGEXP_FUNCTION_INDEX); 1646 Context::REGEXP_FUNCTION_INDEX);
1647 regexp_fun->shared()->SetConstructStub( 1647
1648 *isolate->builtins()->JSBuiltinsConstructStub()); 1648 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate);
1649 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor());
1650 shared->set_instance_class_name(isolate->heap()->RegExp_string());
1651 shared->DontAdaptArguments();
1652 shared->set_length(2);
1653
1654 // Install the "constructor" property on the {prototype}.
1655 JSObject::AddProperty(prototype, factory->constructor_string(), regexp_fun,
1656 DONT_ENUM);
1657
1658 // RegExp.prototype setup.
1659
1660 SimpleInstallFunction(prototype, "exec", Builtins::kRegExpPrototypeExec, 1,
1661 true, DONT_ENUM);
1649 1662
1650 DCHECK(regexp_fun->has_initial_map()); 1663 DCHECK(regexp_fun->has_initial_map());
1651 Handle<Map> initial_map(regexp_fun->initial_map()); 1664 Handle<Map> initial_map(regexp_fun->initial_map());
1652 1665
1653 DCHECK_EQ(0, initial_map->GetInObjectProperties()); 1666 DCHECK_EQ(0, initial_map->GetInObjectProperties());
1654 1667
1655 Map::EnsureDescriptorSlack(initial_map, 1); 1668 Map::EnsureDescriptorSlack(initial_map, 1);
1656 1669
1657 // ECMA-262, section 15.10.7.5. 1670 // ECMA-262, section 15.10.7.5.
1658 PropertyAttributes writable = 1671 PropertyAttributes writable =
1659 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 1672 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1660 DataDescriptor field(factory->last_index_string(), 1673 DataDescriptor field(factory->last_index_string(),
1661 JSRegExp::kLastIndexFieldIndex, writable, 1674 JSRegExp::kLastIndexFieldIndex, writable,
1662 Representation::Tagged()); 1675 Representation::Tagged());
1663 initial_map->AppendDescriptor(&field); 1676 initial_map->AppendDescriptor(&field);
1664 1677
1665 static const int num_fields = JSRegExp::kInObjectFieldCount; 1678 static const int num_fields = JSRegExp::kInObjectFieldCount;
1666 initial_map->SetInObjectProperties(num_fields); 1679 initial_map->SetInObjectProperties(num_fields);
1667 initial_map->set_unused_property_fields(0); 1680 initial_map->set_unused_property_fields(0);
1668 initial_map->set_instance_size(initial_map->instance_size() + 1681 initial_map->set_instance_size(initial_map->instance_size() +
1669 num_fields * kPointerSize); 1682 num_fields * kPointerSize);
1670
1671 // RegExp.prototype setup.
1672
1673 // Install the "constructor" property on the {prototype}.
1674 JSObject::AddProperty(prototype, factory->constructor_string(), regexp_fun,
1675 DONT_ENUM);
1676
1677 SimpleInstallFunction(prototype, "exec", Builtins::kRegExpPrototypeExec, 1,
1678 true, DONT_ENUM);
1679 } 1683 }
1680 1684
1681 { // -- E r r o r 1685 { // -- E r r o r
1682 InstallError(isolate, global, factory->Error_string(), 1686 InstallError(isolate, global, factory->Error_string(),
1683 Context::ERROR_FUNCTION_INDEX); 1687 Context::ERROR_FUNCTION_INDEX);
1684 InstallMakeError(isolate, isolate->builtins()->MakeError(), 1688 InstallMakeError(isolate, isolate->builtins()->MakeError(),
1685 Context::MAKE_ERROR_INDEX); 1689 Context::MAKE_ERROR_INDEX);
1686 } 1690 }
1687 1691
1688 { // -- E v a l E r r o r 1692 { // -- E v a l E r r o r
(...skipping 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after
4196 } 4200 }
4197 4201
4198 4202
4199 // Called when the top-level V8 mutex is destroyed. 4203 // Called when the top-level V8 mutex is destroyed.
4200 void Bootstrapper::FreeThreadResources() { 4204 void Bootstrapper::FreeThreadResources() {
4201 DCHECK(!IsActive()); 4205 DCHECK(!IsActive());
4202 } 4206 }
4203 4207
4204 } // namespace internal 4208 } // namespace internal
4205 } // namespace v8 4209 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | src/builtins/builtins-regexp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698