Diff
Modified: trunk/JSTests/ChangeLog (260311 => 260312)
--- trunk/JSTests/ChangeLog 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/JSTests/ChangeLog 2020-04-18 16:01:02 UTC (rev 260312)
@@ -1,3 +1,13 @@
+2020-04-18 Alexey Shvayka <shvaikal...@gmail.com>
+
+ RegExp.prototype[@@search] should use SameValue
+ https://bugs.webkit.org/show_bug.cgi?id=173226
+
+ Reviewed by Yusuke Suzuki.
+
+ * stress/same-value-intrinsic.js: Added.
+ * test262/expectations.yaml: Mark 4 test cases as passing.
+
2020-04-17 Saam Barati <sbar...@apple.com>
GetTypedArrayByteOffset is broken on arm64e
Added: trunk/JSTests/stress/same-value-intrinsic.js (0 => 260312)
--- trunk/JSTests/stress/same-value-intrinsic.js (rev 0)
+++ trunk/JSTests/stress/same-value-intrinsic.js 2020-04-18 16:01:02 UTC (rev 260312)
@@ -0,0 +1,31 @@
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+const sameValue = $vm.createBuiltin(`(function (a, b) {
+ return @sameValue(a, b);
+})`);
+
+const obj = {};
+const arr = [];
+const sym = Symbol();
+
+for (let i = 0; i < 1e5; ++i) {
+ shouldBe(sameValue(null, null), true);
+ shouldBe(sameValue(null, undefined), false);
+ shouldBe(sameValue(true, true), true);
+ shouldBe(sameValue(true, false), false);
+ shouldBe(sameValue('abc', 'abc'), true);
+ shouldBe(sameValue(NaN, NaN), true);
+ shouldBe(sameValue(Infinity, Infinity), true);
+ shouldBe(sameValue(0, 0), true);
+ shouldBe(sameValue(-0, -0), true);
+ shouldBe(sameValue(0, -0), false);
+ shouldBe(sameValue(-0, 0), false);
+ shouldBe(sameValue(obj, obj), true);
+ shouldBe(sameValue({}, {}), false);
+ shouldBe(sameValue(arr, arr), true);
+ shouldBe(sameValue([], []), false);
+ shouldBe(sameValue(sym, sym), true);
+}
Modified: trunk/JSTests/test262/expectations.yaml (260311 => 260312)
--- trunk/JSTests/test262/expectations.yaml 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/JSTests/test262/expectations.yaml 2020-04-18 16:01:02 UTC (rev 260312)
@@ -1657,12 +1657,6 @@
test/built-ins/RegExp/prototype/Symbol.match/builtin-infer-unicode.js:
default: 'Test262Error: Expected SameValue(«�», «null») to be true'
strict mode: 'Test262Error: Expected SameValue(«�», «null») to be true'
-test/built-ins/RegExp/prototype/Symbol.search/set-lastindex-init-samevalue.js:
- default: 'Test262Error: Expected SameValue(«-0», «0») to be true'
- strict mode: 'Test262Error: Expected SameValue(«-0», «0») to be true'
-test/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore-samevalue.js:
- default: 'Test262Error: Expected SameValue(«-0», «0») to be true'
- strict mode: 'Test262Error: Expected SameValue(«-0», «0») to be true'
test/built-ins/RegExp/prototype/Symbol.search/u-lastindex-advance.js:
default: 'Test262Error: Expected SameValue(«1», «-1») to be true'
strict mode: 'Test262Error: Expected SameValue(«1», «-1») to be true'
Modified: trunk/Source/_javascript_Core/ChangeLog (260311 => 260312)
--- trunk/Source/_javascript_Core/ChangeLog 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-04-18 16:01:02 UTC (rev 260312)
@@ -1,3 +1,24 @@
+2020-04-18 Alexey Shvayka <shvaikal...@gmail.com>
+
+ RegExp.prototype[@@search] should use SameValue
+ https://bugs.webkit.org/show_bug.cgi?id=173226
+
+ Reviewed by Yusuke Suzuki.
+
+ This change exposes Object.is implementation as link-time-constant @sameValue and utilizes
+ it in RegExp.prototype[@@search] per spec [1], aligning JSC with V8 and SpiderMonkey.
+
+ [1]: https://tc39.es/ecma262/#sec-regexp.prototype-@@search (steps 5, 8)
+
+ * builtins/BuiltinNames.h:
+ * builtins/RegExpPrototype.js:
+ (Symbol.search):
+ * bytecode/LinkTimeConstant.h:
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init):
+ * runtime/ObjectConstructor.cpp:
+ * runtime/ObjectConstructor.h:
+
2020-04-18 Angelos Oikonomopoulos <ange...@igalia.com>
Fix code origin when lowering offlineasm instructions on MIPS/ARM64E
Modified: trunk/Source/_javascript_Core/builtins/BuiltinNames.h (260311 => 260312)
--- trunk/Source/_javascript_Core/builtins/BuiltinNames.h 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/builtins/BuiltinNames.h 2020-04-18 16:01:02 UTC (rev 260312)
@@ -122,6 +122,7 @@
macro(instanceOf) \
macro(isArraySlow) \
macro(isConstructor) \
+ macro(sameValue) \
macro(concatMemcpy) \
macro(appendMemcpy) \
macro(regExpCreate) \
Modified: trunk/Source/_javascript_Core/builtins/RegExpPrototype.js (260311 => 260312)
--- trunk/Source/_javascript_Core/builtins/RegExpPrototype.js 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/builtins/RegExpPrototype.js 2020-04-18 16:01:02 UTC (rev 260312)
@@ -403,10 +403,9 @@
// 4. Let previousLastIndex be ? Get(rx, "lastIndex").
var previousLastIndex = regexp.lastIndex;
- // 5.If SameValue(previousLastIndex, 0) is false, then
+ // 5. If SameValue(previousLastIndex, 0) is false, then
// 5.a. Perform ? Set(rx, "lastIndex", 0, true).
- // FIXME: Add SameValue support. https://bugs.webkit.org/show_bug.cgi?id=173226
- if (previousLastIndex !== 0)
+ if (!@sameValue(previousLastIndex, 0))
regexp.lastIndex = 0;
// 6. Let result be ? RegExpExec(rx, S).
@@ -415,8 +414,7 @@
// 7. Let currentLastIndex be ? Get(rx, "lastIndex").
// 8. If SameValue(currentLastIndex, previousLastIndex) is false, then
// 8.a. Perform ? Set(rx, "lastIndex", previousLastIndex, true).
- // FIXME: Add SameValue support. https://bugs.webkit.org/show_bug.cgi?id=173226
- if (regexp.lastIndex !== previousLastIndex)
+ if (!@sameValue(regexp.lastIndex, previousLastIndex))
regexp.lastIndex = previousLastIndex;
// 9. If result is null, return -1.
Modified: trunk/Source/_javascript_Core/bytecode/LinkTimeConstant.h (260311 => 260312)
--- trunk/Source/_javascript_Core/bytecode/LinkTimeConstant.h 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/bytecode/LinkTimeConstant.h 2020-04-18 16:01:02 UTC (rev 260312)
@@ -74,6 +74,7 @@
v(Set, nullptr) \
v(thisTimeValue, nullptr) \
v(isConstructor, nullptr) \
+ v(sameValue, nullptr) \
v(regExpProtoFlagsGetter, nullptr) \
v(regExpProtoGlobalGetter, nullptr) \
v(regExpProtoIgnoreCaseGetter, nullptr) \
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (260311 => 260312)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2020-04-18 16:01:02 UTC (rev 260312)
@@ -1135,6 +1135,9 @@
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::isConstructor)].initLater([] (const Initializer<JSCell>& init) {
init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 1, String(), esSpecIsConstructor, NoIntrinsic));
});
+ m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::sameValue)].initLater([] (const Initializer<JSCell>& init) {
+ init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 2, String(), objectConstructorIs, ObjectIsIntrinsic));
+ });
// RegExp.prototype helpers.
m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::regExpCreate)].initLater([] (const Initializer<JSCell>& init) {
Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp (260311 => 260312)
--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2020-04-18 16:01:02 UTC (rev 260312)
@@ -54,7 +54,6 @@
EncodedJSValue JSC_HOST_CALL objectConstructorIsSealed(JSGlobalObject*, CallFrame*);
EncodedJSValue JSC_HOST_CALL objectConstructorIsFrozen(JSGlobalObject*, CallFrame*);
EncodedJSValue JSC_HOST_CALL objectConstructorIsExtensible(JSGlobalObject*, CallFrame*);
-EncodedJSValue JSC_HOST_CALL objectConstructorIs(JSGlobalObject*, CallFrame*);
}
Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.h (260311 => 260312)
--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.h 2020-04-18 15:57:14 UTC (rev 260311)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.h 2020-04-18 16:01:02 UTC (rev 260312)
@@ -125,4 +125,6 @@
JSArray* ownPropertyKeys(JSGlobalObject*, JSObject*, PropertyNameMode, DontEnumPropertiesMode);
bool toPropertyDescriptor(JSGlobalObject*, JSValue, PropertyDescriptor&);
+EncodedJSValue JSC_HOST_CALL objectConstructorIs(JSGlobalObject*, CallFrame*);
+
} // namespace JSC