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

Side by Side Diff: src/bootstrapper.cc

Issue 2398423002: [regexp] Port RegExp.prototype[@@replace] (Closed)
Patch Set: Smi::kZero 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') | no next file with comments »
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 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 1693 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
1694 prototype, Builtins::kRegExpConstructor); 1694 prototype, Builtins::kRegExpConstructor);
1695 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, 1695 InstallWithIntrinsicDefaultProto(isolate, regexp_fun,
1696 Context::REGEXP_FUNCTION_INDEX); 1696 Context::REGEXP_FUNCTION_INDEX);
1697 1697
1698 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate); 1698 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate);
1699 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor()); 1699 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor());
1700 shared->set_instance_class_name(isolate->heap()->RegExp_string()); 1700 shared->set_instance_class_name(isolate->heap()->RegExp_string());
1701 shared->DontAdaptArguments(); 1701 shared->DontAdaptArguments();
1702 shared->set_length(2); 1702 shared->set_length(2);
1703
1704 { 1703 {
1705 // RegExp.prototype setup. 1704 // RegExp.prototype setup.
1706 1705
1707 // Install the "constructor" property on the {prototype}. 1706 // Install the "constructor" property on the {prototype}.
1708 JSObject::AddProperty(prototype, factory->constructor_string(), 1707 JSObject::AddProperty(prototype, factory->constructor_string(),
1709 regexp_fun, DONT_ENUM); 1708 regexp_fun, DONT_ENUM);
1710 1709
1711 { 1710 {
1712 Handle<JSFunction> fun = SimpleInstallFunction( 1711 Handle<JSFunction> fun = SimpleInstallFunction(
1713 prototype, "exec", Builtins::kRegExpPrototypeExec, 1, true, 1712 prototype, "exec", Builtins::kRegExpPrototypeExec, 1, true,
(...skipping 27 matching lines...) Expand all
1741 1740
1742 { 1741 {
1743 Handle<JSFunction> fun = SimpleCreateFunction( 1742 Handle<JSFunction> fun = SimpleCreateFunction(
1744 isolate, factory->InternalizeUtf8String("[Symbol.match]"), 1743 isolate, factory->InternalizeUtf8String("[Symbol.match]"),
1745 Builtins::kRegExpPrototypeMatch, 1, false); 1744 Builtins::kRegExpPrototypeMatch, 1, false);
1746 InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM); 1745 InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM);
1747 } 1746 }
1748 1747
1749 { 1748 {
1750 Handle<JSFunction> fun = SimpleCreateFunction( 1749 Handle<JSFunction> fun = SimpleCreateFunction(
1750 isolate, factory->InternalizeUtf8String("[Symbol.replace]"),
1751 Builtins::kRegExpPrototypeReplace, 2, true);
1752 InstallFunction(prototype, fun, factory->replace_symbol(), DONT_ENUM);
1753 }
1754
1755 {
1756 Handle<JSFunction> fun = SimpleCreateFunction(
1751 isolate, factory->InternalizeUtf8String("[Symbol.search]"), 1757 isolate, factory->InternalizeUtf8String("[Symbol.search]"),
1752 Builtins::kRegExpPrototypeSearch, 1, false); 1758 Builtins::kRegExpPrototypeSearch, 1, false);
1753 InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM); 1759 InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM);
1754 } 1760 }
1755 1761
1756 { 1762 {
1757 Handle<JSFunction> fun = SimpleCreateFunction( 1763 Handle<JSFunction> fun = SimpleCreateFunction(
1758 isolate, factory->InternalizeUtf8String("[Symbol.split]"), 1764 isolate, factory->InternalizeUtf8String("[Symbol.split]"),
1759 Builtins::kRegExpPrototypeSplit, 2, false); 1765 Builtins::kRegExpPrototypeSplit, 2, false);
1760 InstallFunction(prototype, fun, factory->split_symbol(), DONT_ENUM); 1766 InstallFunction(prototype, fun, factory->split_symbol(), DONT_ENUM);
1761 } 1767 }
1768
1769 // Store the initial RegExp.prototype map. This is used in fast-path
1770 // checks. Do not alter the prototype after this point.
1771 isolate->native_context()->set_regexp_prototype_map(prototype->map());
1762 } 1772 }
1763 1773
1764 { 1774 {
1765 // RegExp getters and setters. 1775 // RegExp getters and setters.
1766 1776
1767 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE. 1777 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE.
1768 // However, that currently breaks layout test expectations. Note that 1778 // However, that currently breaks layout test expectations. Note that
1769 // Firefox sets a couple of these as enumerable. 1779 // Firefox sets a couple of these as enumerable.
1770 // On the other hand, installing attributes as DONT_ENUM matches the draft 1780 // On the other hand, installing attributes as DONT_ENUM matches the draft
1771 // specification at 1781 // specification at
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
4395 } 4405 }
4396 4406
4397 4407
4398 // Called when the top-level V8 mutex is destroyed. 4408 // Called when the top-level V8 mutex is destroyed.
4399 void Bootstrapper::FreeThreadResources() { 4409 void Bootstrapper::FreeThreadResources() {
4400 DCHECK(!IsActive()); 4410 DCHECK(!IsActive());
4401 } 4411 }
4402 4412
4403 } // namespace internal 4413 } // namespace internal
4404 } // namespace v8 4414 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698