Split --harmony-unicode and --harmony-unicode-regexps.
This way we can ship \u{..} escapes in strings / identifiers before shipping /u regexps. BUG= Review URL: https://codereview.chromium.org/903703002 Cr-Commit-Position: refs/heads/master@{#26461}
This commit is contained in:
parent
d21b9a1422
commit
299b369cc9
@ -1596,6 +1596,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
|
||||
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
|
||||
|
||||
@ -1627,6 +1628,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names)
|
||||
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
|
||||
|
||||
@ -1642,14 +1644,15 @@ void Genesis::InitializeGlobal_harmony_regexps() {
|
||||
}
|
||||
|
||||
|
||||
void Genesis::InitializeGlobal_harmony_unicode() {
|
||||
void Genesis::InitializeGlobal_harmony_unicode_regexps() {
|
||||
Handle<JSObject> builtins(native_context()->builtins());
|
||||
|
||||
Handle<HeapObject> flag(FLAG_harmony_unicode ? heap()->true_value()
|
||||
: heap()->false_value());
|
||||
Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value()
|
||||
: heap()->false_value());
|
||||
PropertyAttributes attributes =
|
||||
static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
|
||||
Runtime::DefineObjectProperty(builtins, factory()->harmony_unicode_string(),
|
||||
Runtime::DefineObjectProperty(builtins,
|
||||
factory()->harmony_unicode_regexps_string(),
|
||||
flag, attributes).Assert();
|
||||
}
|
||||
|
||||
@ -2209,6 +2212,7 @@ bool Genesis::InstallExperimentalNatives() {
|
||||
"native harmony-templates.js", NULL};
|
||||
static const char* harmony_sloppy_natives[] = {NULL};
|
||||
static const char* harmony_unicode_natives[] = {NULL};
|
||||
static const char* harmony_unicode_regexps_natives[] = {NULL};
|
||||
static const char* harmony_computed_property_names_natives[] = {NULL};
|
||||
static const char* harmony_rest_parameters_natives[] = {NULL};
|
||||
|
||||
|
@ -177,15 +177,16 @@ DEFINE_IMPLICATION(harmony, es_staging)
|
||||
DEFINE_IMPLICATION(es_staging, harmony)
|
||||
|
||||
// Features that are still work in progress (behind individual flags).
|
||||
#define HARMONY_INPROGRESS(V) \
|
||||
V(harmony_modules, "harmony modules (implies block scoping)") \
|
||||
V(harmony_arrays, "harmony array methods") \
|
||||
V(harmony_array_includes, "harmony Array.prototype.includes") \
|
||||
V(harmony_regexps, "harmony regular expression extensions") \
|
||||
V(harmony_arrow_functions, "harmony arrow functions") \
|
||||
V(harmony_proxies, "harmony proxies") \
|
||||
V(harmony_sloppy, "harmony features in sloppy mode") \
|
||||
V(harmony_unicode, "harmony unicode escapes") \
|
||||
#define HARMONY_INPROGRESS(V) \
|
||||
V(harmony_modules, "harmony modules (implies block scoping)") \
|
||||
V(harmony_arrays, "harmony array methods") \
|
||||
V(harmony_array_includes, "harmony Array.prototype.includes") \
|
||||
V(harmony_regexps, "harmony regular expression extensions") \
|
||||
V(harmony_arrow_functions, "harmony arrow functions") \
|
||||
V(harmony_proxies, "harmony proxies") \
|
||||
V(harmony_sloppy, "harmony features in sloppy mode") \
|
||||
V(harmony_unicode, "harmony unicode escapes") \
|
||||
V(harmony_unicode_regexps, "harmony unicode regexps") \
|
||||
V(harmony_computed_property_names, "harmony computed property names") \
|
||||
V(harmony_rest_parameters, "harmony rest parameters")
|
||||
|
||||
@ -231,6 +232,7 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
|
||||
DEFINE_IMPLICATION(harmony_modules, harmony_scoping)
|
||||
DEFINE_IMPLICATION(harmony_classes, harmony_scoping)
|
||||
DEFINE_IMPLICATION(harmony_classes, harmony_object_literals)
|
||||
DEFINE_IMPLICATION(harmony_unicode_regexps, harmony_unicode)
|
||||
|
||||
|
||||
// Flags for experimental implementation features.
|
||||
|
158
src/heap/heap.h
158
src/heap/heap.h
@ -201,85 +201,85 @@ namespace internal {
|
||||
SMI_ROOT_LIST(V) \
|
||||
V(StringTable, string_table, StringTable)
|
||||
|
||||
#define INTERNALIZED_STRING_LIST(V) \
|
||||
V(Object_string, "Object") \
|
||||
V(proto_string, "__proto__") \
|
||||
V(arguments_string, "arguments") \
|
||||
V(Arguments_string, "Arguments") \
|
||||
V(caller_string, "caller") \
|
||||
V(boolean_string, "boolean") \
|
||||
V(Boolean_string, "Boolean") \
|
||||
V(callee_string, "callee") \
|
||||
V(constructor_string, "constructor") \
|
||||
V(dot_result_string, ".result") \
|
||||
V(eval_string, "eval") \
|
||||
V(empty_string, "") \
|
||||
V(function_string, "function") \
|
||||
V(Function_string, "Function") \
|
||||
V(length_string, "length") \
|
||||
V(name_string, "name") \
|
||||
V(null_string, "null") \
|
||||
V(number_string, "number") \
|
||||
V(Number_string, "Number") \
|
||||
V(nan_string, "NaN") \
|
||||
V(source_string, "source") \
|
||||
V(source_url_string, "source_url") \
|
||||
V(source_mapping_url_string, "source_mapping_url") \
|
||||
V(global_string, "global") \
|
||||
V(ignore_case_string, "ignoreCase") \
|
||||
V(multiline_string, "multiline") \
|
||||
V(sticky_string, "sticky") \
|
||||
V(unicode_string, "unicode") \
|
||||
V(harmony_regexps_string, "harmony_regexps") \
|
||||
V(harmony_unicode_string, "harmony_unicode") \
|
||||
V(input_string, "input") \
|
||||
V(index_string, "index") \
|
||||
V(last_index_string, "lastIndex") \
|
||||
V(object_string, "object") \
|
||||
V(prototype_string, "prototype") \
|
||||
V(string_string, "string") \
|
||||
V(String_string, "String") \
|
||||
V(symbol_string, "symbol") \
|
||||
V(Symbol_string, "Symbol") \
|
||||
V(Map_string, "Map") \
|
||||
V(Set_string, "Set") \
|
||||
V(WeakMap_string, "WeakMap") \
|
||||
V(WeakSet_string, "WeakSet") \
|
||||
V(for_string, "for") \
|
||||
V(for_api_string, "for_api") \
|
||||
V(for_intern_string, "for_intern") \
|
||||
V(private_api_string, "private_api") \
|
||||
V(private_intern_string, "private_intern") \
|
||||
V(Date_string, "Date") \
|
||||
V(char_at_string, "CharAt") \
|
||||
V(undefined_string, "undefined") \
|
||||
V(value_of_string, "valueOf") \
|
||||
V(stack_string, "stack") \
|
||||
V(toJSON_string, "toJSON") \
|
||||
V(KeyedLoadMonomorphic_string, "KeyedLoadMonomorphic") \
|
||||
V(KeyedStoreMonomorphic_string, "KeyedStoreMonomorphic") \
|
||||
V(stack_overflow_string, "kStackOverflowBoilerplate") \
|
||||
V(illegal_access_string, "illegal access") \
|
||||
V(cell_value_string, "%cell_value") \
|
||||
V(illegal_argument_string, "illegal argument") \
|
||||
V(identity_hash_string, "v8::IdentityHash") \
|
||||
V(closure_string, "(closure)") \
|
||||
V(dot_string, ".") \
|
||||
V(compare_ic_string, "==") \
|
||||
V(strict_compare_ic_string, "===") \
|
||||
V(infinity_string, "Infinity") \
|
||||
V(minus_infinity_string, "-Infinity") \
|
||||
V(query_colon_string, "(?:)") \
|
||||
V(Generator_string, "Generator") \
|
||||
V(throw_string, "throw") \
|
||||
V(done_string, "done") \
|
||||
V(value_string, "value") \
|
||||
V(next_string, "next") \
|
||||
V(byte_length_string, "byteLength") \
|
||||
V(byte_offset_string, "byteOffset") \
|
||||
V(minus_zero_string, "-0") \
|
||||
V(Array_string, "Array") \
|
||||
V(Error_string, "Error") \
|
||||
#define INTERNALIZED_STRING_LIST(V) \
|
||||
V(Object_string, "Object") \
|
||||
V(proto_string, "__proto__") \
|
||||
V(arguments_string, "arguments") \
|
||||
V(Arguments_string, "Arguments") \
|
||||
V(caller_string, "caller") \
|
||||
V(boolean_string, "boolean") \
|
||||
V(Boolean_string, "Boolean") \
|
||||
V(callee_string, "callee") \
|
||||
V(constructor_string, "constructor") \
|
||||
V(dot_result_string, ".result") \
|
||||
V(eval_string, "eval") \
|
||||
V(empty_string, "") \
|
||||
V(function_string, "function") \
|
||||
V(Function_string, "Function") \
|
||||
V(length_string, "length") \
|
||||
V(name_string, "name") \
|
||||
V(null_string, "null") \
|
||||
V(number_string, "number") \
|
||||
V(Number_string, "Number") \
|
||||
V(nan_string, "NaN") \
|
||||
V(source_string, "source") \
|
||||
V(source_url_string, "source_url") \
|
||||
V(source_mapping_url_string, "source_mapping_url") \
|
||||
V(global_string, "global") \
|
||||
V(ignore_case_string, "ignoreCase") \
|
||||
V(multiline_string, "multiline") \
|
||||
V(sticky_string, "sticky") \
|
||||
V(unicode_string, "unicode") \
|
||||
V(harmony_regexps_string, "harmony_regexps") \
|
||||
V(harmony_unicode_regexps_string, "harmony_unicode_regexps") \
|
||||
V(input_string, "input") \
|
||||
V(index_string, "index") \
|
||||
V(last_index_string, "lastIndex") \
|
||||
V(object_string, "object") \
|
||||
V(prototype_string, "prototype") \
|
||||
V(string_string, "string") \
|
||||
V(String_string, "String") \
|
||||
V(symbol_string, "symbol") \
|
||||
V(Symbol_string, "Symbol") \
|
||||
V(Map_string, "Map") \
|
||||
V(Set_string, "Set") \
|
||||
V(WeakMap_string, "WeakMap") \
|
||||
V(WeakSet_string, "WeakSet") \
|
||||
V(for_string, "for") \
|
||||
V(for_api_string, "for_api") \
|
||||
V(for_intern_string, "for_intern") \
|
||||
V(private_api_string, "private_api") \
|
||||
V(private_intern_string, "private_intern") \
|
||||
V(Date_string, "Date") \
|
||||
V(char_at_string, "CharAt") \
|
||||
V(undefined_string, "undefined") \
|
||||
V(value_of_string, "valueOf") \
|
||||
V(stack_string, "stack") \
|
||||
V(toJSON_string, "toJSON") \
|
||||
V(KeyedLoadMonomorphic_string, "KeyedLoadMonomorphic") \
|
||||
V(KeyedStoreMonomorphic_string, "KeyedStoreMonomorphic") \
|
||||
V(stack_overflow_string, "kStackOverflowBoilerplate") \
|
||||
V(illegal_access_string, "illegal access") \
|
||||
V(cell_value_string, "%cell_value") \
|
||||
V(illegal_argument_string, "illegal argument") \
|
||||
V(identity_hash_string, "v8::IdentityHash") \
|
||||
V(closure_string, "(closure)") \
|
||||
V(dot_string, ".") \
|
||||
V(compare_ic_string, "==") \
|
||||
V(strict_compare_ic_string, "===") \
|
||||
V(infinity_string, "Infinity") \
|
||||
V(minus_infinity_string, "-Infinity") \
|
||||
V(query_colon_string, "(?:)") \
|
||||
V(Generator_string, "Generator") \
|
||||
V(throw_string, "throw") \
|
||||
V(done_string, "done") \
|
||||
V(value_string, "value") \
|
||||
V(next_string, "next") \
|
||||
V(byte_length_string, "byteLength") \
|
||||
V(byte_offset_string, "byteOffset") \
|
||||
V(minus_zero_string, "-0") \
|
||||
V(Array_string, "Array") \
|
||||
V(Error_string, "Error") \
|
||||
V(RegExp_string, "RegExp")
|
||||
|
||||
#define PRIVATE_SYMBOL_LIST(V) \
|
||||
|
@ -4631,7 +4631,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
||||
// If the 'u' flag is present, only syntax characters can be escaped,
|
||||
// no other identity escapes are allowed. If the 'u' flag is not
|
||||
// present, all identity escapes are allowed.
|
||||
if (!FLAG_harmony_unicode || !unicode_) {
|
||||
if (!FLAG_harmony_unicode_regexps || !unicode_) {
|
||||
builder->AddCharacter(first_digit);
|
||||
Advance(2);
|
||||
} else {
|
||||
@ -4692,7 +4692,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
||||
uc32 value;
|
||||
if (ParseHexEscape(2, &value)) {
|
||||
builder->AddCharacter(value);
|
||||
} else if (!FLAG_harmony_unicode || !unicode_) {
|
||||
} else if (!FLAG_harmony_unicode_regexps || !unicode_) {
|
||||
builder->AddCharacter('x');
|
||||
} else {
|
||||
// If the 'u' flag is present, invalid escapes are not treated as
|
||||
@ -4706,7 +4706,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
||||
uc32 value;
|
||||
if (ParseUnicodeEscape(&value)) {
|
||||
builder->AddCharacter(value);
|
||||
} else if (!FLAG_harmony_unicode || !unicode_) {
|
||||
} else if (!FLAG_harmony_unicode_regexps || !unicode_) {
|
||||
builder->AddCharacter('u');
|
||||
} else {
|
||||
// If the 'u' flag is present, invalid escapes are not treated as
|
||||
@ -4720,7 +4720,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
|
||||
// If the 'u' flag is present, only syntax characters can be escaped, no
|
||||
// other identity escapes are allowed. If the 'u' flag is not present,
|
||||
// all identity escapes are allowed.
|
||||
if (!FLAG_harmony_unicode || !unicode_ ||
|
||||
if (!FLAG_harmony_unicode_regexps || !unicode_ ||
|
||||
IsSyntaxCharacter(current())) {
|
||||
builder->AddCharacter(current());
|
||||
Advance();
|
||||
@ -4991,7 +4991,7 @@ bool RegExpParser::ParseUnicodeEscape(uc32* value) {
|
||||
// Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are
|
||||
// allowed). In the latter case, the number of hex digits between { } is
|
||||
// arbitrary. \ and u have already been read.
|
||||
if (current() == '{' && FLAG_harmony_unicode && unicode_) {
|
||||
if (current() == '{' && FLAG_harmony_unicode_regexps && unicode_) {
|
||||
int start = position();
|
||||
Advance();
|
||||
if (ParseUnlimitedLengthHexNumber(0x10ffff, value)) {
|
||||
@ -5081,7 +5081,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
|
||||
if (ParseHexEscape(2, &value)) {
|
||||
return value;
|
||||
}
|
||||
if (!FLAG_harmony_unicode || !unicode_) {
|
||||
if (!FLAG_harmony_unicode_regexps || !unicode_) {
|
||||
// If \x is not followed by a two-digit hexadecimal, treat it
|
||||
// as an identity escape.
|
||||
return 'x';
|
||||
@ -5097,7 +5097,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
|
||||
if (ParseUnicodeEscape(&value)) {
|
||||
return value;
|
||||
}
|
||||
if (!FLAG_harmony_unicode || !unicode_) {
|
||||
if (!FLAG_harmony_unicode_regexps || !unicode_) {
|
||||
return 'u';
|
||||
}
|
||||
// If the 'u' flag is present, invalid escapes are not treated as
|
||||
@ -5110,7 +5110,8 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
|
||||
// If the 'u' flag is present, only syntax characters can be escaped, no
|
||||
// other identity escapes are allowed. If the 'u' flag is not present, all
|
||||
// identity escapes are allowed.
|
||||
if (!FLAG_harmony_unicode || !unicode_ || IsSyntaxCharacter(result)) {
|
||||
if (!FLAG_harmony_unicode_regexps || !unicode_ ||
|
||||
IsSyntaxCharacter(result)) {
|
||||
Advance();
|
||||
return result;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ function DoConstructRegExp(object, pattern, flags) {
|
||||
flags = (pattern.global ? 'g' : '')
|
||||
+ (pattern.ignoreCase ? 'i' : '')
|
||||
+ (pattern.multiline ? 'm' : '');
|
||||
if (harmony_unicode)
|
||||
if (harmony_unicode_regexps)
|
||||
flags += (pattern.unicode ? 'u' : '');
|
||||
if (harmony_regexps)
|
||||
flags += (pattern.sticky ? 'y' : '');
|
||||
@ -237,7 +237,7 @@ function RegExpToString() {
|
||||
if (this.global) result += 'g';
|
||||
if (this.ignoreCase) result += 'i';
|
||||
if (this.multiline) result += 'm';
|
||||
if (harmony_unicode && this.unicode) result += 'u';
|
||||
if (harmony_unicode_regexps && this.unicode) result += 'u';
|
||||
if (harmony_regexps && this.sticky) result += 'y';
|
||||
return result;
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags,
|
||||
flag = JSRegExp::MULTILINE;
|
||||
break;
|
||||
case 'u':
|
||||
if (!FLAG_harmony_unicode) return JSRegExp::Flags(0);
|
||||
if (!FLAG_harmony_unicode_regexps) return JSRegExp::Flags(0);
|
||||
flag = JSRegExp::UNICODE_ESCAPES;
|
||||
break;
|
||||
case 'y':
|
||||
@ -867,7 +867,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
|
||||
|
||||
Map* map = regexp->map();
|
||||
Object* constructor = map->constructor();
|
||||
if (!FLAG_harmony_regexps && !FLAG_harmony_unicode &&
|
||||
if (!FLAG_harmony_regexps && !FLAG_harmony_unicode_regexps &&
|
||||
constructor->IsJSFunction() &&
|
||||
JSFunction::cast(constructor)->initial_map() == map) {
|
||||
// If we still have the original map, set in-object properties directly.
|
||||
@ -902,7 +902,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
|
||||
JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(),
|
||||
sticky, final).Check();
|
||||
}
|
||||
if (FLAG_harmony_unicode) {
|
||||
if (FLAG_harmony_unicode_regexps) {
|
||||
JSObject::SetOwnPropertyIgnoreAttributes(
|
||||
regexp, factory->unicode_string(), unicode, final).Check();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-regexps --harmony-unicode
|
||||
// Flags: --harmony-regexps --harmony-unicode-regexps
|
||||
|
||||
RegExp.prototype.flags = 'setter should be undefined';
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// ES6 extends the \uxxxx escape and also allows \u{xxxxx}.
|
||||
|
||||
// Flags: --harmony-unicode --harmony-regexps
|
||||
// Flags: --harmony-unicode-regexps --harmony-regexps
|
||||
|
||||
function testRegexpHelper(r) {
|
||||
assertTrue(r.test("foo"));
|
||||
|
@ -25,7 +25,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Flags: --expose-debug-as debug --harmony-unicode
|
||||
// Flags: --expose-debug-as debug --harmony-unicode-regexps
|
||||
// Test the mirror object for regular expression values
|
||||
|
||||
var all_attributes = debug.PropertyAttribute.ReadOnly |
|
||||
|
Loading…
Reference in New Issue
Block a user