[ext-code-space] Remove more Code <-> CodeT roundtrips

... in compiler and other components.

Bug: v8:11880
Change-Id: I3a51c33499e7c7169f171c4be0600d7822dafc27
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3825883
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82391}
This commit is contained in:
ishell@chromium.org 2022-08-11 11:36:32 +02:00 committed by V8 LUCI CQ
parent 89567f1cf7
commit b02b4001fe
7 changed files with 38 additions and 16 deletions

View File

@ -9395,7 +9395,7 @@ JSEntryStubs Isolate::GetJSEntryStubs() {
{i::Builtin::kJSRunMicrotasksEntry,
&entry_stubs.js_run_microtasks_entry_stub}}};
for (auto& pair : stubs) {
i::Code js_entry = FromCodeT(i_isolate->builtins()->code(pair.first));
i::CodeT js_entry = i_isolate->builtins()->code(pair.first);
pair.second->code.start =
reinterpret_cast<const void*>(js_entry.InstructionStart());
pair.second->code.length_in_bytes = js_entry.InstructionSize();

View File

@ -363,9 +363,8 @@ void SetupIsolateDelegate::SetupBuiltinsInternal(Isolate* isolate) {
ReplacePlaceholders(isolate);
// TODO(v8:11880): avoid roundtrips between cdc and code.
#define SET_PROMISE_REJECTION_PREDICTION(Name) \
FromCodeT(builtins->code(Builtin::k##Name)).set_is_promise_rejection(true);
builtins->code(Builtin::k##Name).set_is_promise_rejection(true);
BUILTIN_PROMISE_REJECTION_PREDICTION_LIST(SET_PROMISE_REJECTION_PREDICTION)
#undef SET_PROMISE_REJECTION_PREDICTION

View File

@ -2166,11 +2166,9 @@ BIMODAL_ACCESSOR(JSFunction, SharedFunctionInfo, shared)
#undef JSFUNCTION_BIMODAL_ACCESSOR_WITH_DEP
#undef JSFUNCTION_BIMODAL_ACCESSOR_WITH_DEP_C
CodeRef JSFunctionRef::code() const {
CodeTRef JSFunctionRef::code() const {
CodeT code = object()->code(kAcquireLoad);
// Safe to do a relaxed conversion to Code here since CodeT::code field is
// modified only by GC and the CodeT was acquire-loaded.
return MakeRefAssumeMemoryFence(broker(), FromCodeT(code, kRelaxedLoad));
return MakeRefAssumeMemoryFence(broker(), code);
}
NativeContextRef JSFunctionRef::native_context() const {
@ -2252,16 +2250,40 @@ std::ostream& operator<<(std::ostream& os, const ObjectRef& ref) {
}
}
unsigned CodeRef::GetInlinedBytecodeSize() const {
unsigned value = object()->inlined_bytecode_size();
namespace {
unsigned GetInlinedBytecodeSizeImpl(Code code) {
unsigned value = code.inlined_bytecode_size();
if (value > 0) {
// Don't report inlined bytecode size if the code object was already
// deoptimized.
value = object()->marked_for_deoptimization() ? 0 : value;
value = code.marked_for_deoptimization() ? 0 : value;
}
return value;
}
} // namespace
unsigned CodeRef::GetInlinedBytecodeSize() const {
return GetInlinedBytecodeSizeImpl(*object());
}
unsigned CodeDataContainerRef::GetInlinedBytecodeSize() const {
#ifdef V8_EXTERNAL_CODE_SPACE
CodeDataContainer codet = *object();
if (codet.is_off_heap_trampoline()) {
return 0;
}
// Safe to do a relaxed conversion to Code here since CodeT::code field is
// modified only by GC and the CodeT was acquire-loaded.
Code code = codet.code(kRelaxedLoad);
return GetInlinedBytecodeSizeImpl(code);
#else
UNREACHABLE();
#endif // V8_EXTERNAL_CODE_SPACE
}
#undef BIMODAL_ACCESSOR
#undef BIMODAL_ACCESSOR_B
#undef BIMODAL_ACCESSOR_C

View File

@ -456,7 +456,7 @@ class V8_EXPORT_PRIVATE JSFunctionRef : public JSObjectRef {
ContextRef context() const;
NativeContextRef native_context() const;
SharedFunctionInfoRef shared() const;
CodeRef code() const;
CodeTRef code() const;
bool has_initial_map(CompilationDependencies* dependencies) const;
bool PrototypeRequiresRuntimeLookup(
@ -1015,6 +1015,8 @@ class CodeDataContainerRef : public HeapObjectRef {
DEFINE_REF_CONSTRUCTOR(CodeDataContainer, HeapObjectRef)
Handle<CodeDataContainer> object() const;
unsigned GetInlinedBytecodeSize() const;
};
class InternalizedStringRef : public StringRef {

View File

@ -112,7 +112,8 @@ class GeneratedCode {
return GeneratedCode(isolate, reinterpret_cast<Signature*>(buffer));
}
static GeneratedCode FromCode(Code code) {
template <typename CodeOrCodeT>
static GeneratedCode FromCode(CodeOrCodeT code) {
return FromAddress(code.GetIsolate(), code.entry());
}

View File

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

View File

@ -1211,9 +1211,7 @@ TEST_F(LogTest, BuiltinsNotLoggedAsLazyCompile) {
logger.StopLogging();
i::Isolate* i_isolate = logger.i_isolate();
i::Handle<i::Code> builtin = FromCodeT(
i_isolate->builtins()->code_handle(i::Builtin::kBooleanConstructor),
i_isolate);
i::Handle<i::CodeT> builtin = BUILTIN_CODE(i_isolate, BooleanConstructor);
v8::base::EmbeddedVector<char, 100> buffer;
// Should only be logged as "Builtin" with a name, never as "Function".