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

Unified Diff: src/runtime/runtime-regexp.cc

Issue 1419823010: Implement flag and source getters on RegExp.prototype. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@rproto
Patch Set: new webkit expectations 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
Index: src/runtime/runtime-regexp.cc
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
index 58c14bc182f7ddbe60cc0ab7b3e117401c251c3b..826e1d5864949f4af6b4ebbbd53989e9cbe1c062 100644
--- a/src/runtime/runtime-regexp.cc
+++ b/src/runtime/runtime-regexp.cc
@@ -924,26 +924,14 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, escaped_source,
EscapeRegExpSource(isolate, source));
- Handle<Object> global = factory->ToBoolean(flags.is_global());
- Handle<Object> ignore_case = factory->ToBoolean(flags.is_ignore_case());
- Handle<Object> multiline = factory->ToBoolean(flags.is_multiline());
- Handle<Object> sticky = factory->ToBoolean(flags.is_sticky());
- Handle<Object> unicode = factory->ToBoolean(flags.is_unicode());
-
Map* map = regexp->map();
Object* constructor = map->GetConstructor();
- if (!FLAG_harmony_regexps && !FLAG_harmony_unicode_regexps &&
- constructor->IsJSFunction() &&
+ if (constructor->IsJSFunction() &&
JSFunction::cast(constructor)->initial_map() == map) {
// If we still have the original map, set in-object properties directly.
regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *escaped_source);
- // Both true and false are immovable immortal objects so no need for write
- // barrier.
- regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, *global,
- SKIP_WRITE_BARRIER);
- regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, *ignore_case,
- SKIP_WRITE_BARRIER);
- regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, *multiline,
+ regexp->InObjectPropertyAtPut(JSRegExp::kFlagsFieldIndex,
+ Smi::FromInt(flags.value()),
SKIP_WRITE_BARRIER);
regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
Smi::FromInt(0), SKIP_WRITE_BARRIER);
@@ -958,22 +946,13 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
PropertyAttributes writable =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
Handle<Object> zero(Smi::FromInt(0), isolate);
- JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->source_string(),
- escaped_source, final).Check();
- JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->global_string(),
- global, final).Check();
JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->ignore_case_string(), ignore_case, final).Check();
+ regexp, factory->regexp_source_symbol(), escaped_source, final)
+ .Check();
JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->multiline_string(), multiline, final).Check();
- if (FLAG_harmony_regexps) {
- JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(),
- sticky, final).Check();
- }
- if (FLAG_harmony_unicode_regexps) {
- JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->unicode_string(), unicode, final).Check();
- }
+ regexp, factory->regexp_flags_symbol(),
+ Handle<Smi>(Smi::FromInt(flags.value()), isolate), final)
+ .Check();
JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->last_index_string(), zero, writable).Check();
}
« src/bootstrapper.cc ('K') | « src/objects.h ('k') | test/mjsunit/es6/regexp-flags.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698