1// Copyright 2019 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include 'src/builtins/builtins-regexp-gen.h' 6 7namespace regexp { 8 9@export 10transitioning macro RegExpPrototypeExecBodyFast(implicit context: Context)( 11 receiver: JSReceiver, string: String): JSAny { 12 return RegExpPrototypeExecBody(receiver, string, true); 13} 14 15transitioning macro RegExpPrototypeExecBodySlow(implicit context: Context)( 16 receiver: JSReceiver, string: String): JSAny { 17 return RegExpPrototypeExecBody(receiver, string, false); 18} 19 20// Slow path stub for RegExpPrototypeExec to decrease code size. 21transitioning builtin 22RegExpPrototypeExecSlow(implicit context: Context)( 23 regexp: JSRegExp, string: String): JSAny { 24 return RegExpPrototypeExecBodySlow(regexp, string); 25} 26 27extern macro RegExpBuiltinsAssembler::IsFastRegExpNoPrototype( 28 implicit context: Context)(Object): bool; 29 30// ES#sec-regexp.prototype.exec 31// RegExp.prototype.exec ( string ) 32transitioning javascript builtin RegExpPrototypeExec( 33 js-implicit context: NativeContext, receiver: JSAny)(string: JSAny): JSAny { 34 // Ensure {receiver} is a JSRegExp. 35 const receiver = Cast<JSRegExp>(receiver) otherwise ThrowTypeError( 36 MessageTemplate::kIncompatibleMethodReceiver, 'RegExp.prototype.exec', 37 receiver); 38 const string = ToString_Inline(string); 39 40 return IsFastRegExpNoPrototype(receiver) ? 41 RegExpPrototypeExecBodyFast(receiver, string) : 42 RegExpPrototypeExecSlow(receiver, string); 43} 44} 45