[ext-code-space] Migrate JSRegExp code fields to CodeT

Bug: v8:11880
Change-Id: Idf23521d6cb1885922f92e1050937daa2d29acd7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2968409
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75225}
This commit is contained in:
Igor Sheludko 2021-06-17 16:10:51 +02:00 committed by V8 LUCI CQ
parent 899f4ccdae
commit 39c1f718b5
9 changed files with 29 additions and 22 deletions

View File

@ -553,7 +553,8 @@ TNode<HeapObject> RegExpBuiltinsAssembler::RegExpExecInternal(
#endif
GotoIf(TaggedIsSmi(var_code.value()), &runtime);
TNode<Code> code = CAST(var_code.value());
// TODO(v8:11880): avoid roundtrips between cdc and code.
TNode<Code> code = FromCodeT(CAST(var_code.value()));
Label if_success(this), if_exception(this, Label::kDeferred);
{
@ -625,6 +626,7 @@ TNode<HeapObject> RegExpBuiltinsAssembler::RegExpExecInternal(
MachineType arg9_type = type_tagged;
TNode<JSRegExp> arg9 = regexp;
// TODO(v8:11880): avoid roundtrips between cdc and code.
TNode<RawPtrT> code_entry = LoadCodeObjectEntry(code);
// AIX uses function descriptors on CFunction calls. code_entry in this case

View File

@ -812,8 +812,8 @@ void JSBoundFunction::JSBoundFunctionVerify(Isolate* isolate) {
void JSFunction::JSFunctionVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSFunctionVerify(*this, isolate);
CHECK(code().IsCode());
CHECK(map().is_callable());
CHECK(raw_code(isolate).IsCodeT());
CHECK(map(isolate).is_callable());
Handle<JSFunction> function(*this, isolate);
LookupIterator it(isolate, function, isolate->factory()->prototype_string(),
LookupIterator::OWN_SKIP_INTERCEPTOR);
@ -1348,9 +1348,9 @@ void JSRegExp::JSRegExpVerify(Isolate* isolate) {
Object latin1_bytecode = arr.get(JSRegExp::kIrregexpLatin1BytecodeIndex);
Object uc16_bytecode = arr.get(JSRegExp::kIrregexpUC16BytecodeIndex);
bool is_compiled = latin1_code.IsCode();
bool is_compiled = latin1_code.IsCodeT();
if (is_compiled) {
CHECK_EQ(Code::cast(latin1_code).builtin_id(),
CHECK_EQ(FromCodeT(CodeT::cast(latin1_code)).builtin_id(),
Builtin::kRegExpExperimentalTrampoline);
CHECK_EQ(uc16_code, latin1_code);
@ -1382,11 +1382,11 @@ void JSRegExp::JSRegExpVerify(Isolate* isolate) {
// Code: Compiled irregexp code or trampoline to the interpreter.
CHECK((one_byte_data.IsSmi() &&
Smi::ToInt(one_byte_data) == JSRegExp::kUninitializedValue) ||
one_byte_data.IsCode());
one_byte_data.IsCodeT());
Object uc16_data = arr.get(JSRegExp::kIrregexpUC16CodeIndex);
CHECK((uc16_data.IsSmi() &&
Smi::ToInt(uc16_data) == JSRegExp::kUninitializedValue) ||
uc16_data.IsCode());
uc16_data.IsCodeT());
Object one_byte_bytecode =
arr.get(JSRegExp::kIrregexpLatin1BytecodeIndex);

View File

@ -111,9 +111,9 @@ bool JSRegExp::HasCompiledCode() const {
if (TypeTag() != IRREGEXP) return false;
Smi uninitialized = Smi::FromInt(kUninitializedValue);
#ifdef DEBUG
DCHECK(DataAt(kIrregexpLatin1CodeIndex).IsCode() ||
DCHECK(DataAt(kIrregexpLatin1CodeIndex).IsCodeT() ||
DataAt(kIrregexpLatin1CodeIndex) == uninitialized);
DCHECK(DataAt(kIrregexpUC16CodeIndex).IsCode() ||
DCHECK(DataAt(kIrregexpUC16CodeIndex).IsCodeT() ||
DataAt(kIrregexpUC16CodeIndex) == uninitialized);
DCHECK(DataAt(kIrregexpLatin1BytecodeIndex).IsByteArray() ||
DataAt(kIrregexpLatin1BytecodeIndex) == uninitialized);

View File

@ -183,7 +183,9 @@ MaybeHandle<JSRegExp> JSRegExp::New(Isolate* isolate, Handle<String> pattern,
Object JSRegExp::Code(bool is_latin1) const {
DCHECK_EQ(TypeTag(), JSRegExp::IRREGEXP);
return DataAt(code_index(is_latin1));
Object value = DataAt(code_index(is_latin1));
DCHECK_IMPLIES(V8_EXTERNAL_CODE_SPACE_BOOL, value.IsSmi() || value.IsCodeT());
return value;
}
Object JSRegExp::Bytecode(bool is_latin1) const {

View File

@ -123,8 +123,8 @@ bool ExperimentalRegExp::Compile(Isolate* isolate, Handle<JSRegExp> re) {
*compilation_result->bytecode);
Handle<Code> trampoline = BUILTIN_CODE(isolate, RegExpExperimentalTrampoline);
re->SetDataAt(JSRegExp::kIrregexpLatin1CodeIndex, *trampoline);
re->SetDataAt(JSRegExp::kIrregexpUC16CodeIndex, *trampoline);
re->SetDataAt(JSRegExp::kIrregexpLatin1CodeIndex, ToCodeT(*trampoline));
re->SetDataAt(JSRegExp::kIrregexpUC16CodeIndex, ToCodeT(*trampoline));
re->SetCaptureNameMap(compilation_result->capture_name_map);

View File

@ -305,7 +305,7 @@ int NativeRegExpMacroAssembler::Execute(
Address stack_base = stack_scope.stack()->stack_base();
bool is_one_byte = String::IsOneByteRepresentationUnderneath(input);
Code code = Code::cast(regexp.Code(is_one_byte));
Code code = FromCodeT(CodeT::cast(regexp.Code(is_one_byte)));
RegExp::CallOrigin call_origin = RegExp::CallOrigin::kFromRuntime;
using RegexpMatcherSig = int(

View File

@ -408,7 +408,7 @@ bool RegExpImpl::EnsureCompiledIrregexp(Isolate* isolate, Handle<JSRegExp> re,
}
if (!needs_initial_compilation && !needs_tier_up_compilation) {
DCHECK(compiled_code.IsCode());
DCHECK(compiled_code.IsCodeT());
DCHECK_IMPLIES(FLAG_regexp_interpret_all, bytecode.IsByteArray());
return true;
}
@ -441,7 +441,7 @@ bool RegExpCodeIsValidForPreCompilation(Handle<JSRegExp> re, bool is_one_byte) {
DCHECK_EQ(JSRegExp::kUninitializedValue, entry_value);
DCHECK_EQ(JSRegExp::kUninitializedValue, bytecode_value);
} else {
DCHECK(entry.IsSmi() || (entry.IsCode() && bytecode.IsByteArray()));
DCHECK(entry.IsSmi() || (entry.IsCodeT() && bytecode.IsByteArray()));
}
return true;
@ -493,7 +493,10 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
Handle<FixedArray> data =
Handle<FixedArray>(FixedArray::cast(re->data()), isolate);
if (compile_data.compilation_target == RegExpCompilationTarget::kNative) {
data->set(JSRegExp::code_index(is_one_byte), *compile_data.code);
// TODO(ishell): avoid roundtrips between cdc and code.
Code code = Code::cast(*compile_data.code);
data->set(JSRegExp::code_index(is_one_byte), ToCodeT(code));
// Reset bytecode to uninitialized. In case we use tier-up we know that
// tier-up has happened this way.
data->set(JSRegExp::bytecode_index(is_one_byte),
@ -506,7 +509,7 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
data->set(JSRegExp::bytecode_index(is_one_byte), *compile_data.code);
Handle<Code> trampoline =
BUILTIN_CODE(isolate, RegExpInterpreterTrampoline);
data->set(JSRegExp::code_index(is_one_byte), *trampoline);
data->set(JSRegExp::code_index(is_one_byte), ToCodeT(*trampoline));
}
re->SetCaptureNameMap(compile_data.capture_name_map);
int register_max = IrregexpMaxRegisterCount(*data);

View File

@ -1102,7 +1102,7 @@ RUNTIME_FUNCTION(Runtime_RegexpHasNativeCode) {
CONVERT_BOOLEAN_ARG_CHECKED(is_latin1, 1);
bool result;
if (regexp.TypeTag() == JSRegExp::IRREGEXP) {
result = regexp.Code(is_latin1).IsCode();
result = regexp.Code(is_latin1).IsCodeT();
} else {
result = false;
}

View File

@ -643,7 +643,7 @@ static Handle<JSRegExp> CreateJSRegExp(Handle<String> source, Handle<Code> code,
JSRegExp::kNoBacktrackLimit);
regexp->SetDataAt(is_unicode ? JSRegExp::kIrregexpUC16CodeIndex
: JSRegExp::kIrregexpLatin1CodeIndex,
*code);
ToCodeT(*code));
return regexp;
}
@ -2331,10 +2331,10 @@ TEST(UnicodePropertyEscapeCodeSize) {
if (maybe_bytecode.IsByteArray()) {
// On x64, excessive inlining produced >250KB.
CHECK_LT(ByteArray::cast(maybe_bytecode).Size(), kMaxSize);
} else if (maybe_code.IsCode()) {
} else if (maybe_code.IsCodeT()) {
// On x64, excessive inlining produced >360KB.
CHECK_LT(Code::cast(maybe_code).Size(), kMaxSize);
CHECK_EQ(Code::cast(maybe_code).kind(), CodeKind::REGEXP);
CHECK_LT(FromCodeT(CodeT::cast(maybe_code)).Size(), kMaxSize);
CHECK_EQ(FromCodeT(CodeT::cast(maybe_code)).kind(), CodeKind::REGEXP);
} else {
UNREACHABLE();
}