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

Unified Diff: src/js/regexp.js

Issue 1421593009: Revert of Use in-object fields instead of private symbols for regexp slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/macros.py ('k') | src/js/string.js » ('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 e2b332d749f73dda29121913984b222e7feac3db..79e38ed272cf64e770c1656ecc5cfdf18398b4df 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -14,6 +14,8 @@
var GlobalRegExp = global.RegExp;
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
+var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol");
+var regExpSourceSymbol = utils.ImportNow("regexp_source_symbol");
utils.ImportFromExperimental(function(from) {
FLAG_harmony_tolength = from.FLAG_harmony_tolength;
@@ -332,10 +334,14 @@
// ES6 21.2.5.4, 21.2.5.5, 21.2.5.7, 21.2.5.12, 21.2.5.15.
function GetRegExpFlagGetter(name, mask) {
var getter = function() {
- if (!IS_REGEXP(this)) {
+ if (!IS_SPEC_OBJECT(this)) {
throw MakeTypeError(kRegExpNonObject, name, TO_STRING(this));
}
- return !!(%_RegExpFlags(this) & mask);
+ var flags = this[regExpFlagsSymbol];
+ if (IS_UNDEFINED(flags)) {
+ throw MakeTypeError(kRegExpNonRegExp, TO_STRING(this));
+ }
+ return !!(flags & mask);
};
%FunctionSetName(getter, name);
%SetNativeFlag(getter);
@@ -345,11 +351,15 @@
// ES6 21.2.5.10.
function RegExpGetSource() {
- if (!IS_REGEXP(this)) {
+ if (!IS_SPEC_OBJECT(this)) {
throw MakeTypeError(kRegExpNonObject, "RegExp.prototype.source",
TO_STRING(this));
}
- return %_RegExpSource(this);
+ var source = this[regExpSourceSymbol];
+ if (IS_UNDEFINED(source)) {
+ throw MakeTypeError(kRegExpNonRegExp, TO_STRING(this));
+ }
+ return source;
}
%SetNativeFlag(RegExpGetSource);
« no previous file with comments | « src/js/macros.py ('k') | src/js/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698