Commit 9f64eb09 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space] Avoid Code <-> CodeT conversions in builtins, pt.3

Bug: v8:11880
Change-Id: I53166b226c29a9244b047431e0830de109975306
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3262128Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77760}
parent 3a46c81c
......@@ -75,7 +75,7 @@ static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
}
static_assert(kJavaScriptCallCodeStartRegister == x2, "ABI mismatch");
__ JumpCodeObject(x2);
__ JumpCodeTObject(x2);
}
namespace {
......
......@@ -15,18 +15,18 @@ namespace v8 {
namespace internal {
void LazyBuiltinsAssembler::GenerateTailCallToJSCode(
TNode<Code> code, TNode<JSFunction> function) {
TNode<CodeT> code, TNode<JSFunction> function) {
auto argc = UncheckedParameter<Int32T>(Descriptor::kActualArgumentsCount);
auto context = Parameter<Context>(Descriptor::kContext);
auto new_target = Parameter<Object>(Descriptor::kNewTarget);
TailCallJSCode(code, context, function, new_target, argc);
// TODO(v8:11880): call CodeT directly.
TailCallJSCode(FromCodeT(code), context, function, new_target, argc);
}
void LazyBuiltinsAssembler::GenerateTailCallToReturnedCode(
Runtime::FunctionId function_id, TNode<JSFunction> function) {
auto context = Parameter<Context>(Descriptor::kContext);
TNode<Code> code = CAST(CallRuntime(function_id, context, function));
TNode<CodeT> code = CAST(CallRuntime(function_id, context, function));
GenerateTailCallToJSCode(code, function);
}
......@@ -95,8 +95,7 @@ void LazyBuiltinsAssembler::MaybeTailCallOptimizedCodeSlot(
// the optimized functions list, then tail call the optimized code.
StoreObjectField(function, JSFunction::kCodeOffset, optimized_code);
Comment("MaybeTailCallOptimizedCodeSlot:: GenerateTailCallToJSCode");
// TODO(v8:11880): call CodeT directly.
GenerateTailCallToJSCode(FromCodeT(optimized_code), function);
GenerateTailCallToJSCode(optimized_code, function);
// Optimized code slot contains deoptimized code or code is cleared and
// optimized code marker isn't updated. Evict the code, update the marker
......@@ -164,16 +163,14 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) {
code = Select<CodeT>(
IsFeedbackVector(feedback_cell_value), [=]() { return sfi_code; },
[=]() {
// TODO(v8:11880): avoid roundtrips between cdc and code.
return ToCodeT(CAST(
CallRuntime(Runtime::kInstallBaselineCode,
Parameter<Context>(Descriptor::kContext), function)));
return CAST(CallRuntime(Runtime::kInstallBaselineCode,
Parameter<Context>(Descriptor::kContext),
function));
});
Goto(&tailcall_code);
BIND(&tailcall_code);
// Jump to the selected code entry.
// TODO(v8:11880): call CodeT directly.
GenerateTailCallToJSCode(FromCodeT(code.value()), function);
GenerateTailCallToJSCode(code.value(), function);
BIND(&compile_function);
GenerateTailCallToReturnedCode(Runtime::kCompileLazy, function);
......@@ -191,8 +188,7 @@ TF_BUILTIN(CompileLazyDeoptimizedCode, LazyBuiltinsAssembler) {
TNode<CodeT> code = HeapConstant(BUILTIN_CODET(isolate(), CompileLazy));
// Set the code slot inside the JSFunction to CompileLazy.
StoreObjectField(function, JSFunction::kCodeOffset, code);
// TODO(v8:11880): call CodeT directly.
GenerateTailCallToJSCode(FromCodeT(code), function);
GenerateTailCallToJSCode(code, function);
}
} // namespace internal
......
......@@ -17,7 +17,7 @@ class LazyBuiltinsAssembler : public CodeStubAssembler {
explicit LazyBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
void GenerateTailCallToJSCode(TNode<Code> code, TNode<JSFunction> function);
void GenerateTailCallToJSCode(TNode<CodeT> code, TNode<JSFunction> function);
void GenerateTailCallToReturnedCode(Runtime::FunctionId function_id,
TNode<JSFunction> function);
......
......@@ -78,7 +78,7 @@ static void GenerateTailCallToReturnedCode(
__ Pop(kJavaScriptCallTargetRegister);
}
static_assert(kJavaScriptCallCodeStartRegister == rcx, "ABI mismatch");
__ JumpCodeObject(rcx, jump_mode);
__ JumpCodeTObject(rcx, jump_mode);
}
namespace {
......
......@@ -45,7 +45,8 @@ Object CompileOptimized(Isolate* isolate, Handle<JSFunction> function,
// As a post-condition of CompileOptimized, the function *must* be compiled,
// i.e. the installed Code object must not be the CompileLazy builtin.
DCHECK(function->is_compiled());
return function->code();
// TODO(v8:11880): avoid roundtrips between cdc and code.
return ToCodeT(function->code());
}
} // namespace
......@@ -75,7 +76,8 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) {
return ReadOnlyRoots(isolate).exception();
}
DCHECK(function->is_compiled());
return function->code();
// TODO(v8:11880): avoid roundtrips between cdc and code.
return ToCodeT(function->code());
}
RUNTIME_FUNCTION(Runtime_InstallBaselineCode) {
......@@ -91,7 +93,8 @@ RUNTIME_FUNCTION(Runtime_InstallBaselineCode) {
JSFunction::EnsureFeedbackVector(function, &is_compiled_scope);
Code baseline_code = sfi->baseline_code(kAcquireLoad);
function->set_code(baseline_code);
return baseline_code;
// TODO(v8:11880): avoid roundtrips between cdc and code.
return ToCodeT(baseline_code);
}
RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) {
......@@ -125,7 +128,8 @@ RUNTIME_FUNCTION(Runtime_FunctionFirstExecution) {
function->feedback_vector().ClearOptimizationMarker();
// Return the code to continue execution, we don't care at this point whether
// this is for lazy compilation or has been eagerly complied.
return function->code();
// TODO(v8:11880): avoid roundtrips between cdc and code.
return ToCodeT(function->code());
}
RUNTIME_FUNCTION(Runtime_HealOptimizedCodeSlot) {
......@@ -138,7 +142,8 @@ RUNTIME_FUNCTION(Runtime_HealOptimizedCodeSlot) {
function->feedback_vector().EvictOptimizedCodeMarkedForDeoptimization(
function->raw_feedback_cell(), function->shared(),
"Runtime_HealOptimizedCodeSlot");
return function->code();
// TODO(v8:11880): avoid roundtrips between cdc and code.
return ToCodeT(function->code());
}
RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) {
......
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