DEFINE_BOOL(trace_wasm_compilation_times, false,
"print how long it took to compile each wasm function")
DEFINE_INT(wasm_tier_up_filter, -1, "only tier-up function with this index")
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+DEFINE_BOOL(compile_big_functions_with_one_thread, true,
+ "Compile big WASM functions using only one thread to decrease memory usage")
+#endif
DEFINE_DEBUG_BOOL(trace_wasm_decoder, false, "trace decoding of wasm code")
DEFINE_DEBUG_BOOL(trace_wasm_compiler, false, "trace compiling of wasm code")
DEFINE_DEBUG_BOOL(trace_wasm_streaming, false,
size_t EstimateCurrentMemoryConsumption() const;
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+ bool MarkTopTierUnitCompiled(int unit_id) {
+ const auto was_compiling =
+ big_top_tier_unit_compiling_.compare_exchange_strong(
+ unit_id, kNoUnitCompiling, std::memory_order_relaxed);
+ return was_compiling;
+ }
+
+ static bool IsBigUnit(const NativeModule* module,
+ const WasmCompilationUnit& unit) {
+ const auto func_size =
+ module->module()->functions[unit.func_index()].code.length();
+ return func_size > kBigUnitsLimit;
+ }
+#endif // BUILDING_V8_FOR_TIZEN_TV
+
private:
// Functions bigger than {kBigUnitsLimit} will be compiled first, in ascending
// order of their function body size.
return {};
}
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+ bool CanStartTopTierUnitCompilation(int unit_id) {
+ // A big top tier unit can only be compiled if there isn't any of those
+ // already being compiled.
+ int expected_id = kNoUnitCompiling;
+ return big_top_tier_unit_compiling_.compare_exchange_strong(expected_id,
+ unit_id, std::memory_order_relaxed);
+ }
+#endif // BUILDING_V8_FOR_TIZEN_TV
+
base::Optional<WasmCompilationUnit> GetBigUnitOfTier(int tier) {
// Fast path without locking.
if (!big_units_queue_.has_units[tier].load(std::memory_order_relaxed)) {
base::MutexGuard guard(&big_units_queue_.mutex);
if (big_units_queue_.units[tier].empty()) return {};
WasmCompilationUnit unit = big_units_queue_.units[tier].top().unit;
+
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+ // This is a big unit. Check the tier since we should only interact
+ // with top tier units.
+ if (v8_flags.compile_big_functions_with_one_thread &&
+ unit.tier() == ExecutionTier::kTurbofan &&
+ !CanStartTopTierUnitCompilation(unit.func_index())) {
+ return {};
+ }
+#endif // BUILDING_V8_FOR_TIZEN_TV
+
big_units_queue_.units[tier].pop();
if (big_units_queue_.units[tier].empty()) {
big_units_queue_.has_units[tier].store(false, std::memory_order_relaxed);
std::atomic<size_t> num_priority_units_{0};
std::unique_ptr<std::atomic<bool>[]> top_tier_compiled_;
std::atomic<int> next_queue_to_add{0};
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+ static constexpr int kNoUnitCompiling{-1};
+ std::atomic<int> big_top_tier_unit_compiling_{kNoUnitCompiling};
+#endif // BUILDING_V8_FOR_TIZEN_TV
};
size_t CompilationUnitQueues::EstimateCurrentMemoryConsumption() const {
size_t EstimateCurrentMemoryConsumption() const;
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+ bool MarkTopTierUnitCompiled(int unit_id) {
+ return compilation_unit_queues_.MarkTopTierUnitCompiled(unit_id);
+ }
+#endif // BUILDING_V8_FOR_TIZEN_TV
+
private:
void AddCompilationUnitInternal(CompilationUnitBuilder* builder,
int function_index,
BackgroundCompileScope compile_scope(native_module);
if (compile_scope.cancelled()) return kYield;
+#if defined(BUILDING_V8_FOR_TIZEN_TV)
+ if (v8_flags.compile_big_functions_with_one_thread &&
+ unit->tier() == ExecutionTier::kTurbofan &&
+ CompilationUnitQueues::IsBigUnit(compile_scope.native_module(),
+ *unit)) {
+ compile_scope.compilation_state()->MarkTopTierUnitCompiled(
+ unit->func_index());
+ }
+#endif // BUILDING_V8_FOR_TIZEN_TV
+
if (!results_to_publish.back().succeeded()) {
compile_scope.compilation_state()->SetError();
return kNoMoreUnits;