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

Unified Diff: src/js/regexp.js

Issue 1543723002: Add web compat workarounds for ES2015 RegExp semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test expectations for new workaround Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/js/harmony-regexp.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/regexp.js
diff --git a/src/js/regexp.js b/src/js/regexp.js
index 086f5e5c5e62b466e8ccf81653a6d4ed76979816..d358ce06b55d6070eef78b9d4f1224630db8fc84 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -270,8 +270,17 @@ function TrimRegExp(regexp) {
}
+const kRegExpPrototypeToString = 12;
+
function RegExpToString() {
if (!IS_REGEXP(this)) {
+ // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix;
+ // a UseCounter is incremented to track it.
+ // TODO(littledan): Remove this workaround or standardize it
+ if (this === GlobalRegExpPrototype) {
+ %IncrementUseCounter(kRegExpPrototypeToString);
+ return '/(?:)/';
+ }
throw MakeTypeError(kIncompatibleMethodReceiver,
'RegExp.prototype.toString', this);
}
@@ -491,7 +500,8 @@ function RegExpGetSource() {
// -------------------------------------------------------------------
%FunctionSetInstanceClassName(GlobalRegExp, 'RegExp');
-%FunctionSetPrototype(GlobalRegExp, new GlobalObject());
+const GlobalRegExpPrototype = new GlobalObject();
Yang 2015/12/22 06:31:22 Regexp.js is one of the remaining native scripts t
Dan Ehrenberg 2015/12/22 07:20:42 I think this makes sense, since it'll be a clean u
+%FunctionSetPrototype(GlobalRegExp, GlobalRegExpPrototype);
%AddNamedProperty(
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
« no previous file with comments | « src/js/harmony-regexp.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698