diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-11-08 15:39:11 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-08 15:46:25 +0100 |
commit | 6ca81ad72a3c6fdf16c683335be748f22aaa9a0d (patch) | |
tree | 33c8ee75f729aed76c2c0b89c63f9bf1b4dd66aa /deps/v8/src/builtins/regexp.tq | |
parent | 1eee0b8bf8bba39b600fb16a9223e545e3bac2bc (diff) | |
download | android-node-v8-6ca81ad72a3c6fdf16c683335be748f22aaa9a0d.tar.gz android-node-v8-6ca81ad72a3c6fdf16c683335be748f22aaa9a0d.tar.bz2 android-node-v8-6ca81ad72a3c6fdf16c683335be748f22aaa9a0d.zip |
deps: update V8 to 7.9.317.20
PR-URL: https://github.com/nodejs/node/pull/30020
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/src/builtins/regexp.tq')
-rw-r--r-- | deps/v8/src/builtins/regexp.tq | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/deps/v8/src/builtins/regexp.tq b/deps/v8/src/builtins/regexp.tq index 7352d2738f..e48e7c584d 100644 --- a/deps/v8/src/builtins/regexp.tq +++ b/deps/v8/src/builtins/regexp.tq @@ -22,8 +22,34 @@ namespace regexp { BranchIfFastRegExp_Permissive(o) otherwise return true, return false; } - extern macro RegExpBuiltinsAssembler::RegExpExec(Context, Object, Object): - Object; + const kInvalidRegExpExecResult: constexpr MessageTemplate + generates 'MessageTemplate::kInvalidRegExpExecResult'; + + // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S ) + @export + transitioning macro RegExpExec(implicit context: Context)( + receiver: JSReceiver, string: String): JSAny { + // Take the slow path of fetching the exec property, calling it, and + // verifying its return value. + + const exec = GetProperty(receiver, 'exec'); + + // Is {exec} callable? + typeswitch (exec) { + case (execCallable: Callable): { + const result = Call(context, execCallable, receiver, string); + if (result != Null) { + ThrowIfNotJSReceiver(result, kInvalidRegExpExecResult, ''); + } + return result; + } + case (Object): { + const regexp = Cast<JSRegExp>(receiver) otherwise ThrowTypeError( + kIncompatibleMethodReceiver, 'RegExp.prototype.exec', receiver); + return RegExpPrototypeExecSlow(regexp, string); + } + } + } extern macro RegExpBuiltinsAssembler::RegExpPrototypeExecBodyWithoutResultFast( @@ -161,4 +187,59 @@ namespace regexp { otherwise return SlowFlagsGetter(receiver); return FastFlagsGetter(fastRegexp); } + + extern transitioning macro RegExpBuiltinsAssembler::SlowLoadLastIndex( + implicit context: Context)(JSAny): JSAny; + extern transitioning macro RegExpBuiltinsAssembler::SlowStoreLastIndex( + implicit context: Context)(JSAny, JSAny): void; + + extern macro RegExpBuiltinsAssembler::FastLoadLastIndex(JSRegExp): Smi; + extern macro RegExpBuiltinsAssembler::FastStoreLastIndex(JSRegExp, Smi): void; + + extern builtin + StringIndexOf(implicit context: Context)(String, String, Smi): Smi; + + extern macro + RegExpBuiltinsAssembler::AdvanceStringIndexFast(String, Smi, bool): Smi; + extern macro + RegExpBuiltinsAssembler::AdvanceStringIndexSlow(String, Number, bool): Smi; + + type UseCounterFeature extends int31 + constexpr 'v8::Isolate::UseCounterFeature'; + const kRegExpMatchIsTrueishOnNonJSRegExp: constexpr UseCounterFeature + generates 'v8::Isolate::kRegExpMatchIsTrueishOnNonJSRegExp'; + const kRegExpMatchIsFalseishOnJSRegExp: constexpr UseCounterFeature + generates 'v8::Isolate::kRegExpMatchIsFalseishOnJSRegExp'; + const kRegExpPrototypeSourceGetter: constexpr UseCounterFeature + generates 'v8::Isolate::kRegExpPrototypeSourceGetter'; + + // ES#sec-isregexp IsRegExp ( argument ) + @export + transitioning macro IsRegExp(implicit context: Context)(obj: JSAny): bool { + const receiver = Cast<JSReceiver>(obj) otherwise return false; + + // Check @match. + const value = GetProperty(receiver, MatchSymbolConstant()); + if (value == Undefined) { + return Is<JSRegExp>(receiver); + } + + assert(value != Undefined); + // The common path. Symbol.match exists, equals the RegExpPrototypeMatch + // function (and is thus trueish), and the receiver is a JSRegExp. + if (ToBoolean(value)) { + if (!Is<JSRegExp>(receiver)) { + IncrementUseCounter( + context, SmiConstant(kRegExpMatchIsTrueishOnNonJSRegExp)); + } + return true; + } + + assert(!ToBoolean(value)); + if (Is<JSRegExp>(receiver)) { + IncrementUseCounter( + context, SmiConstant(kRegExpMatchIsFalseishOnJSRegExp)); + } + return false; + } } |