Commit b02b4001 authored by ishell@chromium.org's avatar ishell@chromium.org Committed by V8 LUCI CQ

[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: 's avatarJakob 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}
parent 89567f1c
...@@ -9395,7 +9395,7 @@ JSEntryStubs Isolate::GetJSEntryStubs() { ...@@ -9395,7 +9395,7 @@ JSEntryStubs Isolate::GetJSEntryStubs() {
{i::Builtin::kJSRunMicrotasksEntry, {i::Builtin::kJSRunMicrotasksEntry,
&entry_stubs.js_run_microtasks_entry_stub}}}; &entry_stubs.js_run_microtasks_entry_stub}}};
for (auto& pair : stubs) { 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 = pair.second->code.start =
reinterpret_cast<const void*>(js_entry.InstructionStart()); reinterpret_cast<const void*>(js_entry.InstructionStart());
pair.second->code.length_in_bytes = js_entry.InstructionSize(); pair.second->code.length_in_bytes = js_entry.InstructionSize();
......
...@@ -363,9 +363,8 @@ void SetupIsolateDelegate::SetupBuiltinsInternal(Isolate* isolate) { ...@@ -363,9 +363,8 @@ void SetupIsolateDelegate::SetupBuiltinsInternal(Isolate* isolate) {
ReplacePlaceholders(isolate); ReplacePlaceholders(isolate);
// TODO(v8:11880): avoid roundtrips between cdc and code.
#define SET_PROMISE_REJECTION_PREDICTION(Name) \ #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) BUILTIN_PROMISE_REJECTION_PREDICTION_LIST(SET_PROMISE_REJECTION_PREDICTION)
#undef SET_PROMISE_REJECTION_PREDICTION #undef SET_PROMISE_REJECTION_PREDICTION
......
...@@ -2166,11 +2166,9 @@ BIMODAL_ACCESSOR(JSFunction, SharedFunctionInfo, shared) ...@@ -2166,11 +2166,9 @@ BIMODAL_ACCESSOR(JSFunction, SharedFunctionInfo, shared)
#undef JSFUNCTION_BIMODAL_ACCESSOR_WITH_DEP #undef JSFUNCTION_BIMODAL_ACCESSOR_WITH_DEP
#undef JSFUNCTION_BIMODAL_ACCESSOR_WITH_DEP_C #undef JSFUNCTION_BIMODAL_ACCESSOR_WITH_DEP_C
CodeRef JSFunctionRef::code() const { CodeTRef JSFunctionRef::code() const {
CodeT code = object()->code(kAcquireLoad); CodeT code = object()->code(kAcquireLoad);
// Safe to do a relaxed conversion to Code here since CodeT::code field is return MakeRefAssumeMemoryFence(broker(), code);
// modified only by GC and the CodeT was acquire-loaded.
return MakeRefAssumeMemoryFence(broker(), FromCodeT(code, kRelaxedLoad));
} }
NativeContextRef JSFunctionRef::native_context() const { NativeContextRef JSFunctionRef::native_context() const {
...@@ -2252,16 +2250,40 @@ std::ostream& operator<<(std::ostream& os, const ObjectRef& ref) { ...@@ -2252,16 +2250,40 @@ std::ostream& operator<<(std::ostream& os, const ObjectRef& ref) {
} }
} }
unsigned CodeRef::GetInlinedBytecodeSize() const { namespace {
unsigned value = object()->inlined_bytecode_size();
unsigned GetInlinedBytecodeSizeImpl(Code code) {
unsigned value = code.inlined_bytecode_size();
if (value > 0) { if (value > 0) {
// Don't report inlined bytecode size if the code object was already // Don't report inlined bytecode size if the code object was already
// deoptimized. // deoptimized.
value = object()->marked_for_deoptimization() ? 0 : value; value = code.marked_for_deoptimization() ? 0 : value;
} }
return 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
#undef BIMODAL_ACCESSOR_B #undef BIMODAL_ACCESSOR_B
#undef BIMODAL_ACCESSOR_C #undef BIMODAL_ACCESSOR_C
......
...@@ -456,7 +456,7 @@ class V8_EXPORT_PRIVATE JSFunctionRef : public JSObjectRef { ...@@ -456,7 +456,7 @@ class V8_EXPORT_PRIVATE JSFunctionRef : public JSObjectRef {
ContextRef context() const; ContextRef context() const;
NativeContextRef native_context() const; NativeContextRef native_context() const;
SharedFunctionInfoRef shared() const; SharedFunctionInfoRef shared() const;
CodeRef code() const; CodeTRef code() const;
bool has_initial_map(CompilationDependencies* dependencies) const; bool has_initial_map(CompilationDependencies* dependencies) const;
bool PrototypeRequiresRuntimeLookup( bool PrototypeRequiresRuntimeLookup(
...@@ -1015,6 +1015,8 @@ class CodeDataContainerRef : public HeapObjectRef { ...@@ -1015,6 +1015,8 @@ class CodeDataContainerRef : public HeapObjectRef {
DEFINE_REF_CONSTRUCTOR(CodeDataContainer, HeapObjectRef) DEFINE_REF_CONSTRUCTOR(CodeDataContainer, HeapObjectRef)
Handle<CodeDataContainer> object() const; Handle<CodeDataContainer> object() const;
unsigned GetInlinedBytecodeSize() const;
}; };
class InternalizedStringRef : public StringRef { class InternalizedStringRef : public StringRef {
......
...@@ -112,7 +112,8 @@ class GeneratedCode { ...@@ -112,7 +112,8 @@ class GeneratedCode {
return GeneratedCode(isolate, reinterpret_cast<Signature*>(buffer)); 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()); return FromAddress(code.GetIsolate(), code.entry());
} }
......
...@@ -432,7 +432,7 @@ int NativeRegExpMacroAssembler::Execute( ...@@ -432,7 +432,7 @@ int NativeRegExpMacroAssembler::Execute(
RegExpStackScope stack_scope(isolate); RegExpStackScope stack_scope(isolate);
bool is_one_byte = String::IsOneByteRepresentationUnderneath(input); 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; RegExp::CallOrigin call_origin = RegExp::CallOrigin::kFromRuntime;
using RegexpMatcherSig = using RegexpMatcherSig =
......
...@@ -1211,9 +1211,7 @@ TEST_F(LogTest, BuiltinsNotLoggedAsLazyCompile) { ...@@ -1211,9 +1211,7 @@ TEST_F(LogTest, BuiltinsNotLoggedAsLazyCompile) {
logger.StopLogging(); logger.StopLogging();
i::Isolate* i_isolate = logger.i_isolate(); i::Isolate* i_isolate = logger.i_isolate();
i::Handle<i::Code> builtin = FromCodeT( i::Handle<i::CodeT> builtin = BUILTIN_CODE(i_isolate, BooleanConstructor);
i_isolate->builtins()->code_handle(i::Builtin::kBooleanConstructor),
i_isolate);
v8::base::EmbeddedVector<char, 100> buffer; v8::base::EmbeddedVector<char, 100> buffer;
// Should only be logged as "Builtin" with a name, never as "Function". // Should only be logged as "Builtin" with a name, never as "Function".
......
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