diff --git a/src/builtins/builtins-regexp-gen.cc b/src/builtins/builtins-regexp-gen.cc index d5337323a2..4434828fbc 100644 --- a/src/builtins/builtins-regexp-gen.cc +++ b/src/builtins/builtins-regexp-gen.cc @@ -553,7 +553,8 @@ TNode RegExpBuiltinsAssembler::RegExpExecInternal( #endif GotoIf(TaggedIsSmi(var_code.value()), &runtime); - TNode code = CAST(var_code.value()); + // TODO(v8:11880): avoid roundtrips between cdc and code. + TNode code = FromCodeT(CAST(var_code.value())); Label if_success(this), if_exception(this, Label::kDeferred); { @@ -625,6 +626,7 @@ TNode RegExpBuiltinsAssembler::RegExpExecInternal( MachineType arg9_type = type_tagged; TNode arg9 = regexp; + // TODO(v8:11880): avoid roundtrips between cdc and code. TNode code_entry = LoadCodeObjectEntry(code); // AIX uses function descriptors on CFunction calls. code_entry in this case diff --git a/src/diagnostics/objects-debug.cc b/src/diagnostics/objects-debug.cc index d26900c3da..21031b362c 100644 --- a/src/diagnostics/objects-debug.cc +++ b/src/diagnostics/objects-debug.cc @@ -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 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); diff --git a/src/objects/js-regexp-inl.h b/src/objects/js-regexp-inl.h index 4aa3331f67..0f38daa5e7 100644 --- a/src/objects/js-regexp-inl.h +++ b/src/objects/js-regexp-inl.h @@ -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); diff --git a/src/objects/js-regexp.cc b/src/objects/js-regexp.cc index 0ae91a5ef9..a40219de42 100644 --- a/src/objects/js-regexp.cc +++ b/src/objects/js-regexp.cc @@ -183,7 +183,9 @@ MaybeHandle JSRegExp::New(Isolate* isolate, Handle 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 { diff --git a/src/regexp/experimental/experimental.cc b/src/regexp/experimental/experimental.cc index 500269c40e..3394fe9c57 100644 --- a/src/regexp/experimental/experimental.cc +++ b/src/regexp/experimental/experimental.cc @@ -123,8 +123,8 @@ bool ExperimentalRegExp::Compile(Isolate* isolate, Handle re) { *compilation_result->bytecode); Handle 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); diff --git a/src/regexp/regexp-macro-assembler.cc b/src/regexp/regexp-macro-assembler.cc index 36ef75bc42..234b80797c 100644 --- a/src/regexp/regexp-macro-assembler.cc +++ b/src/regexp/regexp-macro-assembler.cc @@ -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( diff --git a/src/regexp/regexp.cc b/src/regexp/regexp.cc index e4ddb3ecb2..16c4066f26 100644 --- a/src/regexp/regexp.cc +++ b/src/regexp/regexp.cc @@ -408,7 +408,7 @@ bool RegExpImpl::EnsureCompiledIrregexp(Isolate* isolate, Handle 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 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 re, Handle data = Handle(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 re, data->set(JSRegExp::bytecode_index(is_one_byte), *compile_data.code); Handle 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); diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index d26edff3f8..6c0a3788a7 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -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; } diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc index 63495194d4..8862580fb0 100644 --- a/test/cctest/test-regexp.cc +++ b/test/cctest/test-regexp.cc @@ -643,7 +643,7 @@ static Handle CreateJSRegExp(Handle source, Handle 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(); }