Commit 95af75c1 authored by Z Nguyen-Huu's avatar Z Nguyen-Huu Committed by Commit Bot

[builtins] Port some RegExp builtins to Torque

RegExpPrototypeDotAllGetter, RegExpPrototypeGlobalGetter,
RegExpPrototypeIgnoreCaseGetter, RegExpPrototypeMultilineGetter,
RegExpPrototypeStickyGetter, RegExpPrototypeUnicodeGetter.

Bug: v8:8976
Change-Id: I2a5c19256cacc2438a6b40516565960f5c847205
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1764491
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63406}
parent 14f1796f
......@@ -1768,6 +1768,8 @@ extern operator '&' macro Word32And(int32, int32): int32;
extern operator '&' macro Word32And(uint32, uint32): uint32;
extern operator '==' macro
ConstexprInt31Equal(constexpr int31, constexpr int31): constexpr bool;
extern operator '!=' macro
ConstexprInt31NotEqual(constexpr int31, constexpr int31): constexpr bool;
extern operator '>=' macro
ConstexprInt31GreaterThanEqual(
constexpr int31, constexpr int31): constexpr bool;
......
......@@ -847,27 +847,15 @@ namespace internal {
TFJ(RegExpPrototypeCompile, 2, kReceiver, kPattern, kFlags) \
/* ES #sec-regexp.prototype.exec */ \
TFJ(RegExpPrototypeExec, 1, kReceiver, kString) \
/* ES #sec-get-regexp.prototype.dotAll */ \
TFJ(RegExpPrototypeDotAllGetter, 0, kReceiver) \
/* ES #sec-get-regexp.prototype.flags */ \
TFJ(RegExpPrototypeFlagsGetter, 0, kReceiver) \
/* ES #sec-get-regexp.prototype.global */ \
TFJ(RegExpPrototypeGlobalGetter, 0, kReceiver) \
/* ES #sec-get-regexp.prototype.ignorecase */ \
TFJ(RegExpPrototypeIgnoreCaseGetter, 0, kReceiver) \
/* ES #sec-regexp.prototype-@@match */ \
TFJ(RegExpPrototypeMatch, 1, kReceiver, kString) \
/* https://tc39.github.io/proposal-string-matchall/ */ \
TFJ(RegExpPrototypeMatchAll, 1, kReceiver, kString) \
/* ES #sec-get-regexp.prototype.multiline */ \
TFJ(RegExpPrototypeMultilineGetter, 0, kReceiver) \
/* ES #sec-regexp.prototype-@@search */ \
TFJ(RegExpPrototypeSearch, 1, kReceiver, kString) \
/* ES #sec-get-regexp.prototype.sticky */ \
TFJ(RegExpPrototypeStickyGetter, 0, kReceiver) \
CPP(RegExpPrototypeToString) \
/* ES #sec-get-regexp.prototype.unicode */ \
TFJ(RegExpPrototypeUnicodeGetter, 0, kReceiver) \
CPP(RegExpRightContextGetter) \
\
/* ES #sec-regexp.prototype-@@split */ \
......
This diff is collapsed.
......@@ -154,20 +154,17 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
TNode<String> FlagsGetter(Node* const context, Node* const regexp,
bool is_fastpath);
TNode<Int32T> FastFlagGetter(TNode<JSRegExp> regexp, JSRegExp::Flag flag);
TNode<BoolT> FastFlagGetter(TNode<JSRegExp> regexp, JSRegExp::Flag flag);
TNode<BoolT> FastFlagGetterGlobal(TNode<JSRegExp> regexp) {
return ReinterpretCast<BoolT>(FastFlagGetter(regexp, JSRegExp::kGlobal));
return FastFlagGetter(regexp, JSRegExp::kGlobal);
}
TNode<BoolT> FastFlagGetterUnicode(TNode<JSRegExp> regexp) {
return ReinterpretCast<BoolT>(FastFlagGetter(regexp, JSRegExp::kUnicode));
return FastFlagGetter(regexp, JSRegExp::kUnicode);
}
TNode<Int32T> SlowFlagGetter(TNode<Context> context, TNode<Object> regexp,
JSRegExp::Flag flag);
TNode<Int32T> FlagGetter(TNode<Context> context, TNode<Object> regexp,
JSRegExp::Flag flag, bool is_fastpath);
void FlagGetter(TNode<Context> context, TNode<Object> receiver,
JSRegExp::Flag flag, int counter, const char* method_name);
TNode<BoolT> SlowFlagGetter(TNode<Context> context, TNode<Object> regexp,
JSRegExp::Flag flag);
TNode<BoolT> FlagGetter(TNode<Context> context, TNode<Object> regexp,
JSRegExp::Flag flag, bool is_fastpath);
Node* RegExpInitialize(Node* const context, Node* const regexp,
Node* const maybe_pattern, Node* const maybe_flags);
......@@ -207,8 +204,8 @@ class RegExpMatchAllAssembler : public RegExpBuiltinsAssembler {
TNode<Object> CreateRegExpStringIterator(TNode<Context> native_context,
TNode<Object> regexp,
TNode<String> string,
TNode<Int32T> global,
TNode<Int32T> full_unicode);
TNode<BoolT> global,
TNode<BoolT> full_unicode);
void Generate(TNode<Context> context, TNode<Context> native_context,
TNode<Object> receiver, TNode<Object> maybe_string);
};
......
......@@ -6,9 +6,6 @@
namespace regexp {
const kRegExpNonRegExp: constexpr MessageTemplate
generates 'MessageTemplate::kRegExpNonRegExp';
extern runtime IncrementUseCounter(Context, Smi): void;
const kRegExpPrototypeSourceGetter: constexpr int31
generates 'v8::Isolate::kRegExpPrototypeSourceGetter';
......
......@@ -32,4 +32,102 @@ namespace regexp {
extern macro RegExpBuiltinsAssembler::IsReceiverInitialRegExpPrototype(
implicit context: Context)(Object): bool;
type Flag constexpr 'JSRegExp::Flag';
const kGlobal: constexpr Flag
generates 'JSRegExp::kGlobal';
const kIgnoreCase: constexpr Flag
generates 'JSRegExp::kIgnoreCase';
const kMultiline: constexpr Flag
generates 'JSRegExp::kMultiline';
const kDotAll: constexpr Flag
generates 'JSRegExp::kDotAll';
const kSticky: constexpr Flag
generates 'JSRegExp::kSticky';
const kUnicode: constexpr Flag
generates 'JSRegExp::kUnicode';
const kRegExpPrototypeOldFlagGetter: constexpr int31
generates 'v8::Isolate::kRegExpPrototypeOldFlagGetter';
const kRegExpPrototypeStickyGetter: constexpr int31
generates 'v8::Isolate::kRegExpPrototypeStickyGetter';
const kRegExpPrototypeUnicodeGetter: constexpr int31
generates 'v8::Isolate::kRegExpPrototypeUnicodeGetter';
extern macro RegExpBuiltinsAssembler::FastFlagGetter(
JSRegExp, constexpr Flag): bool;
const kRegExpNonRegExp: constexpr MessageTemplate
generates 'MessageTemplate::kRegExpNonRegExp';
extern runtime IncrementUseCounter(Context, Smi): void;
macro FlagGetter(implicit context: Context)(
receiver: Object, flag: constexpr Flag, counter: constexpr int31,
methodName: constexpr string): JSAny {
typeswitch (receiver) {
case (receiver: JSRegExp): {
return SelectBooleanConstant(FastFlagGetter(receiver, flag));
}
case (Object): {
}
}
if (!IsReceiverInitialRegExpPrototype(receiver)) {
ThrowTypeError(kRegExpNonRegExp, methodName);
}
if constexpr (counter != -1) {
IncrementUseCounter(context, SmiConstant(counter));
}
return Undefined;
}
// ES6 21.2.5.4.
// ES #sec-get-regexp.prototype.global
transitioning javascript builtin RegExpPrototypeGlobalGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny {
return FlagGetter(
receiver, kGlobal, kRegExpPrototypeOldFlagGetter,
'RegExp.prototype.global');
}
// ES6 21.2.5.5.
// ES #sec-get-regexp.prototype.ignorecase
transitioning javascript builtin RegExpPrototypeIgnoreCaseGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny {
return FlagGetter(
receiver, kIgnoreCase, kRegExpPrototypeOldFlagGetter,
'RegExp.prototype.ignoreCase');
}
// ES6 21.2.5.7.
// ES #sec-get-regexp.prototype.multiline
transitioning javascript builtin RegExpPrototypeMultilineGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny {
return FlagGetter(
receiver, kMultiline, kRegExpPrototypeOldFlagGetter,
'RegExp.prototype.multiline');
}
// ES #sec-get-regexp.prototype.dotAll
transitioning javascript builtin RegExpPrototypeDotAllGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny {
const kNoCounter: constexpr int31 = -1;
return FlagGetter(receiver, kDotAll, kNoCounter, 'RegExp.prototype.dotAll');
}
// ES6 21.2.5.12.
// ES #sec-get-regexp.prototype.sticky
transitioning javascript builtin RegExpPrototypeStickyGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny {
return FlagGetter(
receiver, kSticky, kRegExpPrototypeStickyGetter,
'RegExp.prototype.sticky');
}
// ES6 21.2.5.15.
// ES #sec-get-regexp.prototype.unicode
transitioning javascript builtin RegExpPrototypeUnicodeGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny {
return FlagGetter(
receiver, kUnicode, kRegExpPrototypeUnicodeGetter,
'RegExp.prototype.unicode');
}
}
......@@ -3524,6 +3524,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
bool ConstexprBoolNot(bool value) { return !value; }
bool ConstexprInt31Equal(int31_t a, int31_t b) { return a == b; }
bool ConstexprInt31NotEqual(int31_t a, int31_t b) { return a != b; }
bool ConstexprInt31GreaterThanEqual(int31_t a, int31_t b) { return a >= b; }
uint32_t ConstexprUint32Add(uint32_t a, uint32_t b) { return a + b; }
int31_t ConstexprInt31Add(int31_t a, int31_t b) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment