Commit 03c85c23 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[regexp] Eliminate all GetIsolates

Remove all uses of GetIsolate/GetHeap by passing Isolate in from all
call sites.

Bug: v8:7786
Change-Id: I64ff8d5796db9d602e86bff4d0b9297cbe700d0d
Reviewed-on: https://chromium-review.googlesource.com/1080819Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53467}
parent f69527ee
......@@ -16341,8 +16341,8 @@ MaybeHandle<JSRegExp> JSRegExp::Initialize(Handle<JSRegExp> regexp,
ASSIGN_RETURN_ON_EXCEPTION(isolate, escaped_source,
EscapeRegExpSource(isolate, source), JSRegExp);
RETURN_ON_EXCEPTION(isolate, RegExpImpl::Compile(regexp, source, flags),
JSRegExp);
RETURN_ON_EXCEPTION(
isolate, RegExpImpl::Compile(isolate, regexp, source, flags), JSRegExp);
regexp->set_source(*escaped_source);
regexp->set_flags(Smi::FromInt(flags));
......
......@@ -39,11 +39,9 @@ int32_t* RegExpImpl::GlobalCache::FetchNext() {
int last_end_index = last_match[1];
if (regexp_->TypeTag() == JSRegExp::ATOM) {
num_matches_ = RegExpImpl::AtomExecRaw(regexp_,
subject_,
last_end_index,
register_array_,
register_array_size_);
num_matches_ =
RegExpImpl::AtomExecRaw(isolate_, regexp_, subject_, last_end_index,
register_array_, register_array_size_);
} else {
int last_start_index = last_match[0];
if (last_start_index == last_end_index) {
......@@ -54,11 +52,9 @@ int32_t* RegExpImpl::GlobalCache::FetchNext() {
num_matches_ = 0; // Signal failed match.
return nullptr;
}
num_matches_ = RegExpImpl::IrregexpExecRaw(regexp_,
subject_,
last_end_index,
register_array_,
register_array_size_);
num_matches_ = RegExpImpl::IrregexpExecRaw(
isolate_, regexp_, subject_, last_end_index, register_array_,
register_array_size_);
}
if (num_matches_ <= 0) return nullptr;
......
This diff is collapsed.
......@@ -73,34 +73,29 @@ class RegExpImpl {
// the implementation wants to store in the data field.
// Returns false if compilation fails.
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Compile(
Handle<JSRegExp> re, Handle<String> pattern, JSRegExp::Flags flags);
Isolate* isolate, Handle<JSRegExp> re, Handle<String> pattern,
JSRegExp::Flags flags);
// See ECMA-262 section 15.10.6.2.
// This function calls the garbage collector if necessary.
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Exec(
Handle<JSRegExp> regexp, Handle<String> subject, int index,
Handle<RegExpMatchInfo> last_match_info);
Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject,
int index, Handle<RegExpMatchInfo> last_match_info);
// Prepares a JSRegExp object with Irregexp-specific data.
static void IrregexpInitialize(Handle<JSRegExp> re,
Handle<String> pattern,
JSRegExp::Flags flags,
static void IrregexpInitialize(Isolate* isolate, Handle<JSRegExp> re,
Handle<String> pattern, JSRegExp::Flags flags,
int capture_register_count);
static void AtomCompile(Handle<JSRegExp> re,
Handle<String> pattern,
JSRegExp::Flags flags,
static void AtomCompile(Isolate* isolate, Handle<JSRegExp> re,
Handle<String> pattern, JSRegExp::Flags flags,
Handle<String> match_pattern);
static int AtomExecRaw(Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
int32_t* output,
static int AtomExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
Handle<String> subject, int index, int32_t* output,
int output_size);
static Handle<Object> AtomExec(Handle<JSRegExp> regexp,
static Handle<Object> AtomExec(Isolate* isolate, Handle<JSRegExp> regexp,
Handle<String> subject, int index,
Handle<RegExpMatchInfo> last_match_info);
......@@ -113,7 +108,7 @@ class RegExpImpl {
// Returns the number of integer spaces required by IrregexpExecOnce
// as its "registers" argument. If the regexp cannot be compiled,
// an exception is set as pending, and this function returns negative.
static int IrregexpPrepare(Handle<JSRegExp> regexp,
static int IrregexpPrepare(Isolate* isolate, Handle<JSRegExp> regexp,
Handle<String> subject);
// Execute a regular expression on the subject, starting from index.
......@@ -122,10 +117,8 @@ class RegExpImpl {
// The captures and subcaptures are stored into the registers vector.
// If matching fails, returns RE_FAILURE.
// If execution fails, sets a pending exception and returns RE_EXCEPTION.
static int IrregexpExecRaw(Handle<JSRegExp> regexp,
Handle<String> subject,
int index,
int32_t* output,
static int IrregexpExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
Handle<String> subject, int index, int32_t* output,
int output_size);
// Execute an Irregexp bytecode pattern.
......@@ -133,14 +126,14 @@ class RegExpImpl {
// captured positions. On a failure, the result is the null value.
// Returns an empty handle in case of an exception.
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> IrregexpExec(
Handle<JSRegExp> regexp, Handle<String> subject, int index,
Handle<RegExpMatchInfo> last_match_info);
Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject,
int index, Handle<RegExpMatchInfo> last_match_info);
// Set last match info. If match is nullptr, then setting captures is
// omitted.
static Handle<RegExpMatchInfo> SetLastMatchInfo(
Handle<RegExpMatchInfo> last_match_info, Handle<String> subject,
int capture_count, int32_t* match);
Isolate* isolate, Handle<RegExpMatchInfo> last_match_info,
Handle<String> subject, int capture_count, int32_t* match);
class GlobalCache {
public:
......@@ -172,6 +165,7 @@ class RegExpImpl {
int register_array_size_;
Handle<JSRegExp> regexp_;
Handle<String> subject_;
Isolate* isolate_;
};
// For acting on the JSRegExp data FixedArray.
......@@ -194,9 +188,10 @@ class RegExpImpl {
static const int kRegExpTooLargeToOptimize = 20 * KB;
private:
static bool CompileIrregexp(Handle<JSRegExp> re,
static bool CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
Handle<String> sample_subject, bool is_one_byte);
static inline bool EnsureCompiledIrregexp(Handle<JSRegExp> re,
static inline bool EnsureCompiledIrregexp(Isolate* isolate,
Handle<JSRegExp> re,
Handle<String> sample_subject,
bool is_one_byte);
};
......@@ -1535,7 +1530,7 @@ class RegExpEngine: public AllStatic {
Handle<String> sample_subject,
bool is_one_byte);
static bool TooMuchRegExpCode(Handle<String> pattern);
static bool TooMuchRegExpCode(Isolate* isolate, Handle<String> pattern);
static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
};
......
......@@ -601,7 +601,8 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
}
int32_t match_indices[] = {indices->back(), indices->back() + pattern_len};
RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices);
RegExpImpl::SetLastMatchInfo(isolate, last_match_info, subject, 0,
match_indices);
TruncateRegexpIndicesList(isolate);
......@@ -620,7 +621,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
JSRegExp::Type typeTag = regexp->TypeTag();
if (typeTag == JSRegExp::IRREGEXP) {
// Ensure the RegExp is compiled so we can access the capture-name map.
if (RegExpImpl::IrregexpPrepare(regexp, subject) == -1) {
if (RegExpImpl::IrregexpPrepare(isolate, regexp, subject) == -1) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
}
......@@ -692,7 +693,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
builder.AddSubjectSlice(prev, subject_length);
}
RegExpImpl::SetLastMatchInfo(last_match_info, subject, capture_count,
RegExpImpl::SetLastMatchInfo(isolate, last_match_info, subject, capture_count,
global_cache.LastSuccessfulMatch());
RETURN_RESULT_OR_FAILURE(isolate, builder.ToString());
......@@ -760,7 +761,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
if (global_cache.HasException()) return isolate->heap()->exception();
RegExpImpl::SetLastMatchInfo(last_match_info, subject, capture_count,
RegExpImpl::SetLastMatchInfo(isolate, last_match_info, subject, capture_count,
global_cache.LastSuccessfulMatch());
if (prev < subject_length) {
......@@ -915,8 +916,8 @@ RUNTIME_FUNCTION(Runtime_RegExpExec) {
CHECK_LE(0, index);
CHECK_GE(subject->length(), index);
isolate->counters()->regexp_entry_runtime()->Increment();
RETURN_RESULT_OR_FAILURE(
isolate, RegExpImpl::Exec(regexp, subject, index, last_match_info));
RETURN_RESULT_OR_FAILURE(isolate, RegExpImpl::Exec(isolate, regexp, subject,
index, last_match_info));
}
RUNTIME_FUNCTION(Runtime_RegExpInternalReplace) {
......@@ -1160,8 +1161,8 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
isolate->factory()->CopyFixedArrayWithMap(
cached_fixed_array, isolate->factory()->fixed_array_map());
JSArray::SetContent(result_array, copied_fixed_array);
RegExpImpl::SetLastMatchInfo(last_match_array, subject, capture_count,
last_match);
RegExpImpl::SetLastMatchInfo(isolate, last_match_array, subject,
capture_count, last_match);
DeleteArray(last_match);
return *result_array;
}
......@@ -1269,7 +1270,8 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
subject_length);
}
RegExpImpl::SetLastMatchInfo(last_match_array, subject, capture_count,
RegExpImpl::SetLastMatchInfo(isolate, last_match_array, subject,
capture_count,
global_cache.LastSuccessfulMatch());
if (subject_length > kMinLengthToCache) {
......@@ -1337,7 +1339,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<String> RegExpReplace(
Handle<Object> match_indices_obj;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, match_indices_obj,
RegExpImpl::Exec(regexp, string, last_index, last_match_info), String);
RegExpImpl::Exec(isolate, regexp, string, last_index, last_match_info),
String);
if (match_indices_obj->IsNull(isolate)) {
if (sticky) regexp->set_last_index(Smi::kZero, SKIP_WRITE_BARRIER);
......@@ -1456,7 +1459,7 @@ RUNTIME_FUNCTION(Runtime_StringReplaceNonGlobalRegExpWithFunction) {
Handle<Object> match_indices_obj;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, match_indices_obj,
RegExpImpl::Exec(regexp, subject, last_index, last_match_info));
RegExpImpl::Exec(isolate, regexp, subject, last_index, last_match_info));
if (match_indices_obj->IsNull(isolate)) {
if (sticky) regexp->set_last_index(Smi::kZero, SKIP_WRITE_BARRIER);
......
......@@ -18,8 +18,9 @@ void Test(v8::Isolate* isolate, i::Handle<i::JSRegExp> regexp,
i::Handle<i::String> subject,
i::Handle<i::RegExpMatchInfo> results_array) {
v8::TryCatch try_catch(isolate);
if (i::RegExpImpl::Exec(regexp, subject, 0, results_array).is_null()) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
if (i::RegExpImpl::Exec(i_isolate, regexp, subject, 0, results_array)
.is_null()) {
i_isolate->OptionalRescheduleException(true);
}
}
......
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