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

Side by Side Diff: src/bootstrapper.cc

Issue 2398423002: [regexp] Port RegExp.prototype[@@replace] (Closed)
Patch Set: Tweaks in string code-stub-assembler methods 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 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 1678 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
1679 prototype, Builtins::kRegExpConstructor); 1679 prototype, Builtins::kRegExpConstructor);
1680 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, 1680 InstallWithIntrinsicDefaultProto(isolate, regexp_fun,
1681 Context::REGEXP_FUNCTION_INDEX); 1681 Context::REGEXP_FUNCTION_INDEX);
1682 1682
1683 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate); 1683 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate);
1684 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor()); 1684 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor());
1685 shared->set_instance_class_name(isolate->heap()->RegExp_string()); 1685 shared->set_instance_class_name(isolate->heap()->RegExp_string());
1686 shared->DontAdaptArguments(); 1686 shared->DontAdaptArguments();
1687 shared->set_length(2); 1687 shared->set_length(2);
1688
1689 { 1688 {
1690 // RegExp.prototype setup. 1689 // RegExp.prototype setup.
1691 1690
1692 // Install the "constructor" property on the {prototype}. 1691 // Install the "constructor" property on the {prototype}.
1693 JSObject::AddProperty(prototype, factory->constructor_string(), 1692 JSObject::AddProperty(prototype, factory->constructor_string(),
1694 regexp_fun, DONT_ENUM); 1693 regexp_fun, DONT_ENUM);
1695 1694
1696 { 1695 {
1697 Handle<JSFunction> fun = SimpleInstallFunction( 1696 Handle<JSFunction> fun = SimpleInstallFunction(
1698 prototype, "exec", Builtins::kRegExpPrototypeExec, 1, true, 1697 prototype, "exec", Builtins::kRegExpPrototypeExec, 1, true,
(...skipping 27 matching lines...) Expand all
1726 1725
1727 { 1726 {
1728 Handle<JSFunction> fun = SimpleCreateFunction( 1727 Handle<JSFunction> fun = SimpleCreateFunction(
1729 isolate, factory->InternalizeUtf8String("[Symbol.match]"), 1728 isolate, factory->InternalizeUtf8String("[Symbol.match]"),
1730 Builtins::kRegExpPrototypeMatch, 1, false); 1729 Builtins::kRegExpPrototypeMatch, 1, false);
1731 InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM); 1730 InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM);
1732 } 1731 }
1733 1732
1734 { 1733 {
1735 Handle<JSFunction> fun = SimpleCreateFunction( 1734 Handle<JSFunction> fun = SimpleCreateFunction(
1735 isolate, factory->InternalizeUtf8String("[Symbol.replace]"),
1736 Builtins::kRegExpPrototypeReplace, 2, true);
1737 InstallFunction(prototype, fun, factory->replace_symbol(), DONT_ENUM);
1738 }
1739
1740 {
1741 Handle<JSFunction> fun = SimpleCreateFunction(
1736 isolate, factory->InternalizeUtf8String("[Symbol.search]"), 1742 isolate, factory->InternalizeUtf8String("[Symbol.search]"),
1737 Builtins::kRegExpPrototypeSearch, 1, false); 1743 Builtins::kRegExpPrototypeSearch, 1, false);
1738 InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM); 1744 InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM);
1739 } 1745 }
1740 1746
1741 { 1747 {
1742 Handle<JSFunction> fun = SimpleCreateFunction( 1748 Handle<JSFunction> fun = SimpleCreateFunction(
1743 isolate, factory->InternalizeUtf8String("[Symbol.split]"), 1749 isolate, factory->InternalizeUtf8String("[Symbol.split]"),
1744 Builtins::kRegExpPrototypeSplit, 2, false); 1750 Builtins::kRegExpPrototypeSplit, 2, false);
1745 InstallFunction(prototype, fun, factory->split_symbol(), DONT_ENUM); 1751 InstallFunction(prototype, fun, factory->split_symbol(), DONT_ENUM);
1746 } 1752 }
1753
1754 // Store the initial RegExp.prototype map. This is used in fast-path
1755 // checks. Do not alter the prototype after this point.
1756 isolate->native_context()->set_regexp_prototype_map(prototype->map());
1747 } 1757 }
1748 1758
1749 { 1759 {
1750 // RegExp getters and setters. 1760 // RegExp getters and setters.
1751 1761
1752 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE. 1762 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE.
1753 // However, that currently breaks layout test expectations. Note that 1763 // However, that currently breaks layout test expectations. Note that
1754 // Firefox sets a couple of these as enumerable. 1764 // Firefox sets a couple of these as enumerable.
1755 // On the other hand, installing attributes as DONT_ENUM matches the draft 1765 // On the other hand, installing attributes as DONT_ENUM matches the draft
1756 // specification at 1766 // specification at
(...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after
4359 } 4369 }
4360 4370
4361 4371
4362 // Called when the top-level V8 mutex is destroyed. 4372 // Called when the top-level V8 mutex is destroyed.
4363 void Bootstrapper::FreeThreadResources() { 4373 void Bootstrapper::FreeThreadResources() {
4364 DCHECK(!IsActive()); 4374 DCHECK(!IsActive());
4365 } 4375 }
4366 4376
4367 } // namespace internal 4377 } // namespace internal
4368 } // namespace v8 4378 } // 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