Reviewers: rossberg,
Description:
Fix source property of empty RegExp objects.
[email protected]
BUG=v8:1982
TEST=test262/15.10.4.1-5
Please review this at https://chromiumcodereview.appspot.com/10134010/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/bootstrapper.cc
M src/heap.h
M src/regexp.js
M src/runtime.cc
M test/mjsunit/regress/regress-1217.js
M test/mozilla/mozilla.status
M test/sputnik/sputnik.status
M test/test262/test262.status
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index
617881555f53c4a520a21f9686f819bb2e0569c3..c65c68c2d75c37b0718b3e944967b22884957bb1
100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1011,7 +1011,7 @@ bool Genesis::InitializeGlobal(Handle<GlobalObject>
inner_global,
proto_map->set_prototype(global_context()->initial_object_prototype());
Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
- heap->empty_string());
+ heap->query_colon_symbol());
proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
heap->false_value());
proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
af86f44ad2588677c3140270b2c0512c6247799c..13a16541e628831658f27655425308064b1950db
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -243,7 +243,8 @@ namespace internal {
V(compare_ic_symbol, ".compare_ic") \
V(infinity_symbol, "Infinity") \
V(minus_infinity_symbol, "-Infinity") \
- V(hidden_stack_trace_symbol, "v8::hidden_stack_trace")
+ V(hidden_stack_trace_symbol, "v8::hidden_stack_trace") \
+ V(query_colon_symbol, "(?:)")
// Forward declarations.
class GCTracer;
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index
7bcb612b5e0d3e2d8ac0b07812565dceb0ad4a48..a574f62bf6a040b808bc40ea380f8a497f2261fe
100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -278,11 +278,7 @@ function TrimRegExp(regexp) {
function RegExpToString() {
- // If this.source is an empty string, output /(?:)/.
- // http://bugzilla.mozilla.org/show_bug.cgi?id=225550
- // ecma_2/RegExp/properties-001.js.
- var src = this.source ? this.source : '(?:)';
- var result = '/' + src + '/';
+ var result = '/' + this.source + '/';
if (this.global) result += 'g';
if (this.ignoreCase) result += 'i';
if (this.multiline) result += 'm';
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
a344b28e0a030bcfc2410849ad8fa5a65b26153e..39310123e48440d33e0f59bcd576aec2270cbdea
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1780,6 +1780,9 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_RegExpInitializeObject) {
ASSERT(args.length() == 5);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
CONVERT_ARG_CHECKED(String, source, 1);
+ // If source is the empty string we set it to "(?:)" instead as
+ // suggested by ECMA-262, 5th, section 15.10.4.1.
+ if (source->length() == 0) source =
isolate->heap()->query_colon_symbol();
Object* global = args[2];
if (!global->IsTrue()) global = isolate->heap()->false_value();
Index: test/mjsunit/regress/regress-1217.js
diff --git a/test/mjsunit/regress/regress-1217.js
b/test/mjsunit/regress/regress-1217.js
index
65305498645644acd5118309e5b8b29aff4136b2..e00d5371ad84da131eacd40c17836b0962762336
100644
--- a/test/mjsunit/regress/regress-1217.js
+++ b/test/mjsunit/regress/regress-1217.js
@@ -30,7 +30,7 @@
var proto = RegExp.prototype;
assertEquals("[object RegExp]", Object.prototype.toString.call(proto));
-assertEquals("", proto.source);
+assertEquals("(?:)", proto.source);
assertEquals(false, proto.global);
assertEquals(false, proto.multiline);
assertEquals(false, proto.ignoreCase);
Index: test/mozilla/mozilla.status
diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status
index
9eafb4bc3cff5e16fb9078623ca2ab2786fb3d5e..c30be5e095002207dfe3997dd444e840d9cac639
100644
--- a/test/mozilla/mozilla.status
+++ b/test/mozilla/mozilla.status
@@ -600,6 +600,12 @@ ecma_2/RegExp/hex-001: FAIL_OK
js1_2/regexp/hexadecimal: FAIL_OK
+# The source field of RegExp objects is properly escaped. We match JSC.
+ecma_2/RegExp/constructor-001: FAIL_OK
+ecma_2/RegExp/function-001: FAIL_OK
+ecma_2/RegExp/properties-001: FAIL_OK
+
+
##################### FAILING TESTS #####################
# This section is for tests that fail in V8 and pass in JSC.
Index: test/sputnik/sputnik.status
diff --git a/test/sputnik/sputnik.status b/test/sputnik/sputnik.status
index
5cda6fd6eeec05792d5d3098bb03ea52d561f6b5..52d126e65b6c3f5ffd67aac3cdbceaa1951a1cf8
100644
--- a/test/sputnik/sputnik.status
+++ b/test/sputnik/sputnik.status
@@ -124,6 +124,16 @@ S15.3.4.2_A1_T1: FAIL_OK
S8.5_A2.2: PASS, FAIL if $system == linux, FAIL if $system == macos
S8.5_A2.1: PASS, FAIL if $system == linux, FAIL if $system == macos
+# The source field of RegExp objects is properly escaped. We match JSC.
+S15.10.4.1_A3_T1: FAIL_OK
+S15.10.4.1_A3_T2: FAIL_OK
+S15.10.4.1_A3_T3: FAIL_OK
+S15.10.4.1_A3_T4: FAIL_OK
+S15.10.4.1_A3_T5: FAIL_OK
+S15.10.4.1_A4_T2: FAIL_OK
+S15.10.4.1_A4_T3: FAIL_OK
+S15.10.4.1_A4_T5: FAIL_OK
+
##################### ES3 TESTS #########################
# These tests check for ES3 semantics, and differ from ES5.
# When we follow ES5 semantics, it's ok to fail the test.
Index: test/test262/test262.status
diff --git a/test/test262/test262.status b/test/test262/test262.status
index
98e27bad0f9273ac970e6fec84f6f0d1396996a8..4993fbbdac3537e1d74abe2712bb41ae037780e2
100644
--- a/test/test262/test262.status
+++ b/test/test262/test262.status
@@ -44,9 +44,6 @@ S15.12.2_A1: FAIL
15.2.3.6-4-415: FAIL
15.2.3.6-4-420: FAIL
-# V8 Bug: http://code.google.com/p/v8/issues/detail?id=1982
-15.10.4.1-5: FAIL
-
##################### DELIBERATE INCOMPATIBILITIES #####################
# We deliberately treat arguments to parseInt() with a leading zero as
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev