Lines Matching defs:function
52 #include "src/objects/js-function-inl.h"
55 #include "src/objects/shared-function-info.h"
79 void SetTieringState(JSFunction function, BytecodeOffset osr_offset,
82 function.set_osr_tiering_state(value);
84 function.set_tiering_state(value);
88 void ResetTieringState(JSFunction function, BytecodeOffset osr_offset) {
89 if (function.has_feedback_vector()) {
90 SetTieringState(function, osr_offset, TieringState::kNone);
94 void ResetProfilerTicks(JSFunction function, BytecodeOffset osr_offset) {
96 // Reset profiler ticks, the function is no longer considered hot.
98 function.feedback_vector().set_profiler_ticks(0);
123 static void TraceOptimizeOSR(Isolate* isolate, Handle<JSFunction> function,
129 "[OSR - started. function: %s, osr offset: %d, mode: %s]\n",
130 function->DebugNameCStr().get(), osr_offset.ToInt(), ToString(mode));
134 Handle<JSFunction> function,
140 "[OSR - unavailable (failed or in progress). function: %s, osr "
142 function->DebugNameCStr().get(), osr_offset.ToInt(), ToString(mode));
186 Handle<JSFunction> function,
191 PrintTracePrefix(scope, "found optimized code for", function, code_kind);
199 Handle<JSFunction> function,
203 PrintTracePrefix(scope, "optimizing", function, code_kind);
209 Handle<JSFunction> function) {
213 function->ShortPrint(scope.file());
226 const char* header, Handle<JSFunction> function,
229 function->ShortPrint(scope.file());
489 Handle<JSFunction> function = compilation_info()->closure();
502 code_size += function->shared().SourceSize();
643 // If the function failed asm-wasm compilation, mark asm_wasm as broken
717 // Finalize a single compilation job. This function can return
829 // Ensure that the top level function is retained.
898 Isolate* isolate, Handle<JSFunction> function, BytecodeOffset osr_offset,
903 SharedFunctionInfo shared = function->shared();
909 code = function->native_context().osr_code_cache().TryGet(
913 if (function->has_feedback_vector()) {
914 FeedbackVector feedback_vector = function->feedback_vector();
929 CompilerTracer::TraceOptimizedCodeCacheHit(isolate, function, osr_offset,
939 Handle<JSFunction> function = compilation_info->closure();
940 Isolate* isolate = function->GetIsolate();
947 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
948 Handle<NativeContext> native_context(function->native_context(), isolate);
957 // Function context specialization folds-in the function context, so no
959 if (function->feedback_vector().has_optimized_code()) {
960 function->feedback_vector().ClearOptimizedCode();
965 function->feedback_vector().SetOptimizedCode(code);
1025 Handle<JSFunction> function = compilation_info->closure();
1030 function->ShortPrint();
1039 function->ShortPrint();
1059 function->ShortPrint();
1063 SetTieringState(*function, compilation_info->osr_offset(),
1091 Handle<JSFunction> function,
1109 compiler::Pipeline::NewCompilationJob(isolate, function,
1134 Handle<JSFunction> function) {
1136 AbstractCode::cast(FromCodeT(function->code())), isolate);
1137 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
1139 Handle<FeedbackVector> feedback_vector(function->feedback_vector(), isolate);
1150 MaybeHandle<CodeT> CompileMaglev(Isolate* isolate, Handle<JSFunction> function,
1174 auto job = maglev::MaglevCompilationJob::New(isolate, function);
1179 function->reset_tiering_state();
1195 RecordMaglevFunctionCompilation(isolate, function);
1196 return handle(function->code(), isolate);
1204 // Remember that the function is currently being processed.
1205 SetTieringState(*function, osr_offset, TieringState::kInProgress);
1214 Isolate* isolate, Handle<JSFunction> function, ConcurrencyMode mode,
1220 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
1222 // Clear the optimization marker on the function so that we don't try to
1225 ResetTieringState(*function, osr_offset);
1240 // Do not optimize if optimization is disabled or function doesn't pass
1247 PendingOptimizationTable::FunctionWasOptimized(isolate, function);
1251 if (OptimizedCodeCache::Get(isolate, function, osr_offset, code_kind)
1258 ResetProfilerTicks(*function, osr_offset);
1261 return CompileTurbofan(isolate, function, shared, mode, osr_offset,
1265 return CompileMaglev(isolate, function, mode, osr_offset, osr_frame,
1275 Handle<JSFunction> function,
1288 USE(GetOrCompileOptimized(isolate, function, ConcurrencyMode::kConcurrent,
1411 // Create shared function info for top level and shared function infos array for
1445 // rest of the function into account to avoid overlap with the
1461 // Prepare and execute compilation of the outer-most function.
1659 // Get preparsed scope data from the function literal.
1983 // We should never reach here if the function is already compiled.
2060 bool Compiler::Compile(Isolate* isolate, Handle<JSFunction> function,
2063 // We should never reach here if the function is already compiled or
2065 DCHECK(!function->is_compiled());
2066 DCHECK(IsNone(function->tiering_state()));
2067 DCHECK(!function->HasAvailableOptimizedCode());
2071 function->ResetIfCodeFlushed();
2073 Handle<SharedFunctionInfo> shared_info = handle(function->shared(), isolate);
2075 // Ensure shared function info is compiled.
2091 JSFunction::InitializeFeedbackCell(function, is_compiled_scope, true);
2095 if (FLAG_always_opt && !function->shared().HasAsmWasmData()) {
2099 CompilerTracer::TraceOptimizeForAlwaysOpt(isolate, function,
2108 SpawnDuplicateConcurrentJobForStressTesting(isolate, function,
2113 if (GetOrCompileOptimized(isolate, function, concurrency_mode, code_kind)
2120 function->set_code(*code, kReleaseStore);
2124 JSFunction::EnsureFeedbackVector(isolate, function, is_compiled_scope);
2129 DCHECK(function->shared().is_compiled());
2130 DCHECK(function->is_compiled());
2139 // We shouldn't be passing uncompiled functions into this function.
2187 bool Compiler::CompileBaseline(Isolate* isolate, Handle<JSFunction> function,
2190 Handle<SharedFunctionInfo> shared(function->shared(isolate), isolate);
2196 JSFunction::EnsureFeedbackVector(isolate, function, is_compiled_scope);
2200 function->set_code(baseline_code);
2206 bool Compiler::CompileMaglev(Isolate* isolate, Handle<JSFunction> function,
2216 JSFunction::EnsureFeedbackVector(isolate, function, is_compiled_scope);
2218 MaybeHandle<CodeT> maybe_code = Maglev::Compile(isolate, function);
2223 function->set_code(*code);
2257 void Compiler::CompileOptimized(Isolate* isolate, Handle<JSFunction> function,
2265 SpawnDuplicateConcurrentJobForStressTesting(isolate, function, mode,
2270 if (GetOrCompileOptimized(isolate, function, mode, code_kind)
2272 function->set_code(*code, kReleaseStore);
2277 DCHECK(function->is_compiled());
2278 DCHECK(function->shared().HasBytecodeArray());
2279 const TieringState tiering_state = function->tiering_state();
2281 DCHECK_IMPLIES(IsInProgress(tiering_state), function->ChecksTieringState());
2308 // Function("", "function anonymous(\n/**/) {\n}");
2368 summary.AsJavaScript().function()->shared());
2956 // until it dies at the end of this function, after which this new
3331 // Find any previously allocated shared function info for the given literal.
3334 // If we found an existing shared function info, return it.
3337 // If the function has been uncompiled (bytecode flushed) it will have lost
3339 // this function, replace the uncompiled data with one that includes it.
3363 // Allocate a shared function info object which will be compiled lazily.
3377 Handle<JSFunction> function,
3385 if (V8_UNLIKELY(function->shared().optimization_disabled())) return {};
3392 if (V8_UNLIKELY(!function->has_feedback_vector())) return {};
3394 // One OSR job per function at a time.
3395 if (IsInProgress(function->osr_tiering_state())) {
3404 // the one installed on the function (e.g. patched by debugger). This however
3411 CompilerTracer::TraceOptimizeOSR(isolate, function, osr_offset, mode);
3413 isolate, function, mode, CodeKind::TURBOFAN, osr_offset, frame);
3416 CompilerTracer::TraceOptimizeOSRUnavailable(isolate, function, osr_offset,
3426 Handle<JSFunction> function = job->compilation_info()->closure();
3427 ResetTieringState(*function, job->compilation_info()->osr_offset());
3429 function->set_code(function->shared().GetCode(), kReleaseStore);
3444 Handle<JSFunction> function = compilation_info->closure();
3451 ResetProfilerTicks(*function, osr_offset);
3457 // 2) The function may have already been optimized by OSR. Simply continue.
3469 ResetTieringState(*function, osr_offset);
3475 "[OSR - requesting install. function: %s, osr offset: %d]\n",
3476 function->DebugNameCStr().get(), osr_offset.ToInt());
3480 function->set_code(*compilation_info->code(), kReleaseStore);
3490 ResetTieringState(*function, osr_offset);
3492 function->set_code(shared->GetCode(), kReleaseStore);
3503 RecordMaglevFunctionCompilation(isolate, job->function());
3509 void Compiler::PostInstantiation(Handle<JSFunction> function) {
3510 Isolate* isolate = function->GetIsolate();
3511 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
3519 JSFunction::InitializeFeedbackCell(function, &is_compiled_scope, false);
3521 if (function->has_feedback_vector()) {
3526 function->feedback_vector().EvictOptimizedCodeMarkedForDeoptimization(
3527 *shared, "new function from shared function info");
3528 CodeT code = function->feedback_vector().optimized_code();
3532 DCHECK(function->shared().is_compiled());
3538 function->set_code(code);
3544 !function->HasAvailableOptimizedCode()) {
3545 CompilerTracer::TraceMarkForAlwaysOpt(isolate, function);
3546 JSFunction::EnsureFeedbackVector(isolate, function, &is_compiled_scope);
3547 function->MarkForOptimization(isolate, CodeKind::TURBOFAN,