Changeset 196498 in webkit
- Timestamp:
- Feb 12, 2016 12:46:30 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196479 r196498 1 2016-02-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [ES6] Implement @@search 4 https://bugs.webkit.org/show_bug.cgi?id=143889 5 6 Reviewed by Darin Adler. 7 8 * js/Object-getOwnPropertyNames-expected.txt: 9 * js/dom/string-prototype-properties-expected.txt: 10 * js/regress/script-tests/v8-regexp-search.js: Added. 11 (runRegExpBenchmark.runBlock0): 12 (runRegExpBenchmark.runBlock1): 13 (runRegExpBenchmark): 14 (runRegExpBenchmark.runBlock3): 15 (runRegExpBenchmark.runBlock4): 16 * js/regress/v8-regexp-search-expected.txt: Added. 17 * js/regress/v8-regexp-search.html: Added. 18 * js/script-tests/Object-getOwnPropertyNames.js: 19 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt: 20 1 21 2016-02-12 Ryan Haddad <ryanhaddad@apple.com> 2 22 -
trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
r196274 r196498 62 62 PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc'] 63 63 PASS getSortedOwnPropertyNames(JSON) is ['parse', 'stringify'] 64 PASS getSortedOwnPropertyNames(Symbol) is ['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'name', 'prototype', 's pecies', 'toStringTag', 'unscopables']64 PASS getSortedOwnPropertyNames(Symbol) is ['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'search', 'species', 'toStringTag', 'unscopables'] 65 65 PASS getSortedOwnPropertyNames(Symbol.prototype) is ['constructor', 'toString', 'valueOf'] 66 66 PASS getSortedOwnPropertyNames(Map) is ['length', 'name', 'prototype'] -
trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt
r194394 r196498 13 13 PASS String.prototype.match.call(undefined, /2+/) threw exception TypeError: Type error. 14 14 PASS String.prototype.replace.call(undefined, /2+/, '-') threw exception TypeError: Type error. 15 PASS String.prototype.search.call(undefined, '4') threw exception TypeError: Type error.15 PASS String.prototype.search.call(undefined, '4') threw exception TypeError: String.prototype.search requires that |this| not be undefined. 16 16 PASS String.prototype.slice.call(undefined, 1, 3) threw exception TypeError: Type error. 17 17 PASS String.prototype.split.call(undefined, '2') threw exception TypeError: Type error. -
trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
r196274 r196498 71 71 "Math": "['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']", 72 72 "JSON": "['parse', 'stringify']", 73 "Symbol": "['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'name', 'prototype', 's pecies', 'toStringTag', 'unscopables']",73 "Symbol": "['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'search', 'species', 'toStringTag', 'unscopables']", 74 74 "Symbol.prototype": "['constructor', 'toString', 'valueOf']", 75 75 "Map": "['length', 'name', 'prototype']", -
trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt
r153221 r196498 1 1 S15.5.4.12_A1_T3 2 2 3 FAIL TypeError: Type error3 FAIL TypeError: String.prototype.search requires that |this| not be undefined 4 4 5 5 TEST COMPLETE -
trunk/Source/JavaScriptCore/CMakeLists.txt
r196077 r196498 828 828 runtime/StringConstructor.cpp 829 829 runtime/StringIteratorPrototype.cpp 830 runtime/StringPrototype.cpp 830 831 runtime/SymbolConstructor.cpp 831 832 runtime/SymbolPrototype.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r196497 r196498 1 2016-02-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [ES6] Implement @@search 4 https://bugs.webkit.org/show_bug.cgi?id=143889 5 6 Reviewed by Darin Adler. 7 8 Implement RegExp.prototype[@@search]. 9 In ES6, String.prototype.search delegates the actual matching to it 10 instead of executing RegExp matching inside String.prototype.search method itself. 11 By customizing @@search method, we can change the behavior of String.prototype.search for 12 derived / customized RegExp object. 13 14 * CMakeLists.txt: 15 * DerivedSources.make: 16 * builtins/BuiltinNames.h: 17 (JSC::BuiltinNames::BuiltinNames): Deleted. 18 * builtins/BuiltinUtils.h: 19 * builtins/StringPrototype.js: 20 (search): 21 * bytecode/BytecodeIntrinsicRegistry.cpp: 22 (JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry): 23 * bytecode/BytecodeIntrinsicRegistry.h: 24 * runtime/CommonIdentifiers.h: 25 * runtime/JSGlobalObject.cpp: 26 (JSC::JSGlobalObject::init): 27 * runtime/RegExpPrototype.cpp: 28 (JSC::RegExpPrototype::finishCreation): 29 (JSC::regExpProtoFuncSearch): 30 * runtime/RegExpPrototype.h: 31 (JSC::RegExpPrototype::create): 32 * runtime/StringPrototype.cpp: 33 (JSC::StringPrototype::getOwnPropertySlot): 34 (JSC::StringPrototype::finishCreation): Deleted. 35 (JSC::stringProtoFuncSearch): Deleted. 36 * runtime/StringPrototype.h: 37 * tests/es6.yaml: 38 * tests/stress/regexp-search.js: Added. 39 (shouldBe): 40 (shouldThrow): 41 (errorKey.toString): 42 (primitive.of.primitives.shouldThrow): 43 (testRegExpSearch): 44 (testSearch): 45 (testBoth): 46 (alwaysUnmatch): 47 1 48 2016-02-12 Keith Miller <keith_miller@apple.com> 2 49 -
trunk/Source/JavaScriptCore/DerivedSources.make
r195999 r196498 151 151 StringConstructor.lut.h \ 152 152 StringIteratorPrototype.lut.h \ 153 StringPrototype.lut.h \ 153 154 SymbolConstructor.lut.h \ 154 155 SymbolPrototype.lut.h \ -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r190401 r196498 48 48 JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALIZE_PRIVATE_TO_PUBLIC_ENTRY) 49 49 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PRIVATE_TO_PUBLIC_ENTRY) 50 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALIZE_PRIVATE_TO_PUBLIC_ENTRY)51 50 JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALIZE_PUBLIC_TO_PRIVATE_ENTRY) 52 51 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PUBLIC_TO_PRIVATE_ENTRY) 53 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALIZE_PUBLIC_TO_PRIVATE_ENTRY)54 52 } 55 53 -
trunk/Source/JavaScriptCore/builtins/BuiltinUtils.h
r190155 r196498 38 38 const JSC::Identifier& name##PrivateName() const { return m_##name##PrivateName; } 39 39 40 #define INITIALIZE_BUILTIN_SYMBOLS(name) INITIALIZE_BUILTIN_NAMES(name), m_##name##Symbol(JSC::Identifier::fromUid(JSC::PrivateName(JSC::PrivateName::Description, ASCIILiteral("Symbol." #name))))41 #define DECLARE_BUILTIN_SYMBOLS(name) DECLARE_BUILTIN_NAMES(name)const JSC::Identifier m_##name##Symbol;40 #define INITIALIZE_BUILTIN_SYMBOLS(name) , m_##name##Symbol(JSC::Identifier::fromUid(JSC::PrivateName(JSC::PrivateName::Description, ASCIILiteral("Symbol." #name)))) 41 #define DECLARE_BUILTIN_SYMBOLS(name) const JSC::Identifier m_##name##Symbol; 42 42 #define DECLARE_BUILTIN_SYMBOL_ACCESSOR(name) \ 43 DECLARE_BUILTIN_IDENTIFIER_ACCESSOR(name) \44 43 const JSC::Identifier& name##Symbol() const { return m_##name##Symbol; } 45 44 -
trunk/Source/JavaScriptCore/builtins/StringPrototype.js
r196022 r196498 1 1 /* 2 2 * Copyright (C) 2015 Andy VanWagoner <thetalecrafter@gmail.com>. 3 * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 59 60 return collator.compare(thisString, thatString); 60 61 } 62 63 function search(regexp) 64 { 65 "use strict"; 66 67 if (this == null) { 68 if (this === null) 69 throw new @TypeError("String.prototype.search requires that |this| not be null"); 70 throw new @TypeError("String.prototype.search requires that |this| not be undefined"); 71 } 72 73 if (regexp != null) { 74 var searcher = regexp[@symbolSearch]; 75 if (searcher !== @undefined) 76 return searcher.@call(regexp, this); 77 } 78 79 var thisString = @toString(this); 80 var createdRegExp = new @RegExp(regexp, @undefined); 81 return createdRegExp[@symbolSearch](thisString); 82 } -
trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
r196022 r196498 52 52 m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected))); 53 53 m_symbolIterator.set(m_vm, Symbol::create(m_vm, static_cast<SymbolImpl&>(*m_vm.propertyNames->iteratorSymbol.impl()))); 54 m_symbolSearch.set(m_vm, Symbol::create(m_vm, static_cast<SymbolImpl&>(*m_vm.propertyNames->searchSymbol.impl()))); 54 55 } 55 56 -
trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h
r196276 r196498 53 53 macro(promiseStateFulfilled) \ 54 54 macro(promiseStateRejected) \ 55 macro(symbolIterator) 55 macro(symbolIterator) \ 56 macro(symbolSearch) 56 57 57 58 class BytecodeIntrinsicRegistry { -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r196494 r196498 274 274 macro(match) \ 275 275 macro(replace) \ 276 macro(search) \277 276 macro(split) \ 278 277 macro(toPrimitive) … … 281 280 macro(hasInstance) \ 282 281 macro(iterator) \ 282 macro(search) \ 283 283 macro(species) \ 284 284 macro(toStringTag) \ … … 306 306 macro(Array) \ 307 307 macro(String) \ 308 macro(RegExp) \ 308 309 macro(Map) \ 309 310 macro(Promise) \ -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r196276 r196498 361 361 RegExp* emptyRegex = RegExp::create(vm, "", NoFlags); 362 362 363 m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex));363 m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex)); 364 364 m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get())); 365 365 m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, *this)); … … 545 545 GlobalPropertyInfo(vm.propertyNames->ArrayPrivateName, arrayConstructor, DontEnum | DontDelete | ReadOnly), 546 546 GlobalPropertyInfo(vm.propertyNames->NumberPrivateName, numberConstructor, DontEnum | DontDelete | ReadOnly), 547 GlobalPropertyInfo(vm.propertyNames->RegExpPrivateName, m_regExpConstructor.get(), DontEnum | DontDelete | ReadOnly), 547 548 GlobalPropertyInfo(vm.propertyNames->StringPrivateName, stringConstructor, DontEnum | DontDelete | ReadOnly), 548 549 GlobalPropertyInfo(vm.propertyNames->absPrivateName, privateFuncAbs, DontEnum | DontDelete | ReadOnly), -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r185528 r196498 36 36 #include "RegExp.h" 37 37 #include "RegExpCache.h" 38 #include "RegExpConstructor.h" 38 39 #include "StringRecursionChecker.h" 39 40 … … 44 45 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*); 45 46 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*); 47 static EncodedJSValue JSC_HOST_CALL regExpProtoFuncSearch(ExecState*); 46 48 static EncodedJSValue JSC_HOST_CALL regExpProtoGetterGlobal(ExecState*); 47 49 static EncodedJSValue JSC_HOST_CALL regExpProtoGetterIgnoreCase(ExecState*); … … 75 77 : RegExpObject(vm, structure, regExp) 76 78 { 79 } 80 81 void RegExpPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) 82 { 83 Base::finishCreation(vm); 84 ASSERT(inherits(info())); 85 JSC_NATIVE_FUNCTION(vm.propertyNames->searchSymbol, regExpProtoFuncSearch, DontEnum, 1); 77 86 } 78 87 … … 348 357 } 349 358 359 EncodedJSValue JSC_HOST_CALL regExpProtoFuncSearch(ExecState* exec) 360 { 361 JSValue thisValue = exec->thisValue(); 362 if (!thisValue.inherits(RegExpObject::info())) 363 return throwVMTypeError(exec); 364 RegExp* regExp = asRegExpObject(thisValue)->regExp(); 365 366 JSString* string = exec->argument(0).toString(exec); 367 String s = string->value(exec); 368 if (exec->hadException()) 369 return JSValue::encode(jsUndefined()); 370 371 RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor(); 372 MatchResult result = regExpConstructor->performMatch(exec->vm(), regExp, string, s, 0); 373 return JSValue::encode(result ? jsNumber(result.start) : jsNumber(-1)); 374 } 375 350 376 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.h
r182747 r196498 32 32 static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot; 33 33 34 static RegExpPrototype* create(VM& vm, Structure* structure, RegExp* regExp)34 static RegExpPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp) 35 35 { 36 36 RegExpPrototype* prototype = new (NotNull, allocateCell<RegExpPrototype>(vm.heap)) RegExpPrototype(vm, structure, regExp); 37 prototype->finishCreation(vm );37 prototype->finishCreation(vm, globalObject); 38 38 return prototype; 39 39 } … … 50 50 51 51 private: 52 void finishCreation(VM&, JSGlobalObject*); 52 53 static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); 53 54 }; -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r196240 r196498 101 101 EncodedJSValue JSC_HOST_CALL stringProtoFuncIterator(ExecState*); 102 102 103 const ClassInfo StringPrototype::s_info = { "String", &StringObject::s_info, 0, CREATE_METHOD_TABLE(StringPrototype) }; 103 } 104 105 #include "StringPrototype.lut.h" 106 107 namespace JSC { 108 109 const ClassInfo StringPrototype::s_info = { "String", &StringObject::s_info, &stringPrototypeTable, CREATE_METHOD_TABLE(StringPrototype) }; 110 111 /* Source for StringConstructor.lut.h 112 @begin stringPrototypeTable 113 search JSBuiltin DontEnum|Function 1 114 @end 115 */ 104 116 105 117 // ECMA 15.5.4 … … 125 137 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("repeat", stringProtoFuncRepeat, DontEnum, 1); 126 138 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("replace", stringProtoFuncReplace, DontEnum, 2); 127 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("search", stringProtoFuncSearch, DontEnum, 1);128 139 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("slice", stringProtoFuncSlice, DontEnum, 2); 129 140 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("split", stringProtoFuncSplit, DontEnum, 2); … … 177 188 } 178 189 190 bool StringPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot &slot) 191 { 192 return getStaticFunctionSlot<Base>(exec, stringPrototypeTable, jsCast<StringPrototype*>(object), propertyName, slot); 193 } 194 179 195 // ------------------------------ Functions -------------------------- 180 196 … … 1021 1037 } 1022 1038 1023 EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState* exec)1024 {1025 JSValue thisValue = exec->thisValue();1026 if (!checkObjectCoercible(thisValue))1027 return throwVMTypeError(exec);1028 JSString* string = thisValue.toString(exec);1029 String s = string->value(exec);1030 VM* vm = &exec->vm();1031 1032 JSValue a0 = exec->argument(0);1033 1034 RegExp* reg;1035 if (a0.inherits(RegExpObject::info()))1036 reg = asRegExpObject(a0)->regExp();1037 else {1038 /*1039 * ECMA 15.5.4.12 String.prototype.search (regexp)1040 * If regexp is not an object whose [[Class]] property is "RegExp", it is1041 * replaced with the result of the expression new RegExp(regexp).1042 * Per ECMA 15.10.4.1, if a0 is undefined substitute the empty string.1043 */1044 reg = RegExp::create(exec->vm(), a0.isUndefined() ? emptyString() : a0.toString(exec)->value(exec), NoFlags);1045 if (!reg->isValid())1046 return throwVMError(exec, createSyntaxError(exec, reg->errorMessage()));1047 }1048 RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();1049 MatchResult result = regExpConstructor->performMatch(*vm, reg, string, s, 0);1050 return JSValue::encode(result ? jsNumber(result.start) : jsNumber(-1));1051 }1052 1053 1039 EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec) 1054 1040 { -
trunk/Source/JavaScriptCore/runtime/StringPrototype.h
r182747 r196498 34 34 public: 35 35 typedef StringObject Base; 36 static const unsigned StructureFlags = Base::StructureFlags;36 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | Base::StructureFlags; 37 37 38 38 static StringPrototype* create(VM&, JSGlobalObject*, Structure*); … … 47 47 protected: 48 48 void finishCreation(VM&, JSGlobalObject*, JSString*); 49 50 private: 51 static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); 49 52 }; 50 53 -
trunk/Source/JavaScriptCore/tests/es6.yaml
r196040 r196498 1084 1084 cmd: runES6 :fail 1085 1085 - path: es6/RegExp.prototype_properties_RegExp.prototype[Symbol.search].js 1086 cmd: runES6 : fail1086 cmd: runES6 :normal 1087 1087 - path: es6/RegExp.prototype_properties_RegExp.prototype[Symbol.split].js 1088 1088 cmd: runES6 :fail … … 1194 1194 cmd: runES6 :fail 1195 1195 - path: es6/well-known_symbols_Symbol.search.js 1196 cmd: runES6 : fail1196 cmd: runES6 :normal 1197 1197 - path: es6/well-known_symbols_Symbol.species_Array.prototype.concat.js 1198 1198 cmd: runES6 :normal
Note: See TracChangeset
for help on using the changeset viewer.