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