Commit 483d8b9b authored by yangguo's avatar yangguo Committed by Commit bot

Unify setting accessor properties in native code.

R=cbruni@chromium.org

Review URL: https://codereview.chromium.org/1416093006

Cr-Commit-Position: refs/heads/master@{#31910}
parent 12a073e6
......@@ -36,8 +36,6 @@ function RegExpGetFlags() {
if (this.sticky) result += 'y';
return result;
}
%FunctionSetName(RegExpGetFlags, "RegExp.prototype.flags");
%SetNativeFlag(RegExpGetFlags);
// ES6 21.2.5.12.
......@@ -61,12 +59,8 @@ function RegExpGetUnicode() {
%FunctionSetName(RegExpGetUnicode, "RegExp.prototype.unicode");
%SetNativeFlag(RegExpGetUnicode);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, 'flags',
RegExpGetFlags, DONT_ENUM);
utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags);
utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky);
utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "sticky",
RegExpGetSticky, DONT_ENUM);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "unicode",
RegExpGetUnicode, DONT_ENUM);
})
......@@ -994,9 +994,8 @@ function MakeURIError() {
// Boilerplate for exceptions for stack overflows. Used from
// Isolate::StackOverflow().
var StackOverflowBoilerplate = MakeRangeError(kStackOverflow);
%DefineAccessorPropertyUnchecked(StackOverflowBoilerplate, 'stack',
StackTraceGetter, StackTraceSetter,
DONT_ENUM);
utils.InstallGetterSetter(StackOverflowBoilerplate, 'stack',
StackTraceGetter, StackTraceSetter)
// Define actual captureStackTrace function after everything has been set up.
captureStackTrace = function captureStackTrace(obj, cons_opt) {
......
......@@ -102,21 +102,20 @@ function InstallFunctions(object, attributes, functions) {
// Helper function to install a getter-only accessor property.
function InstallGetter(object, name, getter, attributes) {
function InstallGetter(object, name, getter, attributes, prefix) {
%CheckIsBootstrapping();
if (typeof attributes == "undefined") {
attributes = DONT_ENUM;
}
SetFunctionName(getter, name, "get");
if (IS_UNDEFINED(attributes)) attributes = DONT_ENUM;
SetFunctionName(getter, name, IS_UNDEFINED(prefix) ? "get" : prefix);
%FunctionRemovePrototype(getter);
%DefineAccessorPropertyUnchecked(object, name, getter, null, attributes);
%DefineGetterPropertyUnchecked(object, name, getter, attributes);
%SetNativeFlag(getter);
}
// Helper function to install a getter/setter accessor property.
function InstallGetterSetter(object, name, getter, setter) {
function InstallGetterSetter(object, name, getter, setter, attributes) {
%CheckIsBootstrapping();
if (IS_UNDEFINED(attributes)) attributes = DONT_ENUM;
SetFunctionName(getter, name, "get");
SetFunctionName(setter, name, "set");
%FunctionRemovePrototype(getter);
......
......@@ -387,14 +387,10 @@ utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"compile", RegExpCompileJS
]);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "global",
RegExpGetGlobal, DONT_ENUM);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "ignoreCase",
RegExpGetIgnoreCase, DONT_ENUM);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "multiline",
RegExpGetMultiline, DONT_ENUM);
%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "source",
RegExpGetSource, DONT_ENUM);
utils.InstallGetter(GlobalRegExp.prototype, 'global', RegExpGetGlobal);
utils.InstallGetter(GlobalRegExp.prototype, 'ignoreCase', RegExpGetIgnoreCase);
utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline);
utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource);
// The length of compile is 1 in SpiderMonkey.
%FunctionSetLength(GlobalRegExp.prototype.compile, 1);
......@@ -411,38 +407,36 @@ var RegExpSetInput = function(string) {
};
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
%DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput,
RegExpSetInput, DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput,
RegExpSetInput, DONT_ENUM | DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, 'input', RegExpGetInput, RegExpSetInput,
DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, '$_', RegExpGetInput, RegExpSetInput,
DONT_ENUM | DONT_DELETE);
var NoOpSetter = function(ignored) {};
// Static properties set by a successful match.
%DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch,
utils.InstallGetterSetter(GlobalRegExp, 'lastMatch', RegExpGetLastMatch,
NoOpSetter, DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch,
NoOpSetter, DONT_ENUM | DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen,
utils.InstallGetterSetter(GlobalRegExp, '$&', RegExpGetLastMatch, NoOpSetter,
DONT_ENUM | DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, 'lastParen', RegExpGetLastParen,
NoOpSetter, DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, '$+', RegExpGetLastParen,
NoOpSetter, DONT_ENUM | DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, 'leftContext',
RegExpGetLeftContext, NoOpSetter,
DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, '$`', RegExpGetLeftContext,
NoOpSetter, DONT_ENUM | DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, 'rightContext',
RegExpGetRightContext, NoOpSetter,
DONT_DELETE);
%DefineAccessorPropertyUnchecked(GlobalRegExp, "$'", RegExpGetRightContext,
NoOpSetter, DONT_ENUM | DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, '$+', RegExpGetLastParen, NoOpSetter,
DONT_ENUM | DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, 'leftContext', RegExpGetLeftContext,
NoOpSetter, DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, '$`', RegExpGetLeftContext, NoOpSetter,
DONT_ENUM | DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, 'rightContext', RegExpGetRightContext,
NoOpSetter, DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, "$'", RegExpGetRightContext, NoOpSetter,
DONT_ENUM | DONT_DELETE);
for (var i = 1; i < 10; ++i) {
%DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i,
RegExpMakeCaptureGetter(i), NoOpSetter,
DONT_DELETE);
utils.InstallGetterSetter(GlobalRegExp, '$' + i, RegExpMakeCaptureGetter(i),
NoOpSetter, DONT_DELETE);
}
%ToFastProperties(GlobalRegExp);
......
......@@ -52,7 +52,7 @@ assertEquals(4, get_count);
function testName(name) {
assertThrows(() => RegExp.prototype[name], TypeError);
assertEquals(
"RegExp.prototype." + name,
"get " + name,
Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name);
}
......
......@@ -343,7 +343,6 @@
'built-ins/RegExp/prototype/test/u-captured-value': [FAIL],
'built-ins/RegExp/prototype/test/u-lastindex-adv': [FAIL],
'built-ins/RegExp/prototype/test/u-lastindex-value': [FAIL],
'built-ins/RegExp/prototype/unicode/name': [FAIL],
'built-ins/RegExp/prototype/unicode/this-regexp': [FAIL],
'built-ins/RegExp/unicode_identity_escape': [FAIL],
'language/literals/regexp/u-unicode-esc': [FAIL],
......@@ -396,16 +395,8 @@
'built-ins/String/prototype/split/cstm-split-get-err': [FAIL],
# https://code.google.com/p/v8/issues/detail?id=4346
'built-ins/RegExp/prototype/flags/name': [FAIL],
'built-ins/RegExp/prototype/flags/u': [FAIL],
# https://code.google.com/p/v8/issues/detail?id=4347
'built-ins/RegExp/prototype/global/name': [FAIL],
'built-ins/RegExp/prototype/ignoreCase/name': [FAIL],
'built-ins/RegExp/prototype/multiline/name': [FAIL],
'built-ins/RegExp/prototype/source/name': [FAIL],
'built-ins/RegExp/prototype/sticky/name': [FAIL],
# https://code.google.com/p/v8/issues/detail?id=4360
'intl402/Collator/10.1.1_1': [FAIL],
'intl402/DateTimeFormat/12.1.1_1': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment