Lines Matching defs:code
2 // Use of this source code is governed by a BSD-style license that can be
10 #include "src/diagnostics/code-tracer.h"
175 // threads, but we need the URL available for code logging.
176 // The shared pointer is kept alive by unlogged code, even if this entry is
294 // Compute the hash as a combined hash of the sections up to the code section
331 // Set of dead code. Filled with all potentially dead code on initialization.
364 // Before destructing, the {WasmEngine} must have cleared outstanding code
376 // Caches whether code needs to be logged on this isolate.
382 // Maps script ID to vector of code objects that still need to be logged, and
385 std::vector<WasmCode*> code;
429 // Set of potentially dead code. This set holds one ref for each code object,
430 // until code is detected to be really dead. At that point, the ref count is
431 // decremented and code is move to the {dead_code} set. If the code is finally
439 // Number of code GCs triggered because code in this native module became
561 // Ensure that code GC will check this isolate for live code.
620 // The JS code executed during instantiation has thrown an exception.
1020 // The isolate might access existing (cached) code without ever compiling any.
1068 for (WasmCode* code : module->potentially_dead_code) {
1069 current_gc_info_->dead_code.erase(code);
1082 WasmCode::DecrementRefCount(base::VectorOf(log_entry.second.code));
1107 for (WasmCode* code : code_vec) {
1108 DCHECK_EQ(native_module, code->native_module());
1109 code->IncRef();
1120 log_entry.code.insert(log_entry.code.end(), code_vec.begin(),
1133 // Under the mutex, get the vector of wasm code to log. Then log and decrement
1142 // Check again whether we still need to log code.
1147 for (WasmCode* code : pair.second.code) {
1149 code->LogCode(isolate, pair.second.source_url.get(), pair.first);
1152 WasmCode::DecrementRefCount(base::VectorOf(pair.second.code));
1281 auto part_of_native_module = [native_module](WasmCode* code) {
1282 return code->native_module() == native_module;
1284 std::vector<WasmCode*>& code = log_entry.second.code;
1286 std::remove_if(code.begin(), code.end(), part_of_native_module);
1287 code.erase(new_end, code.end());
1292 if (it->second.code.empty()) {
1299 // If there is a GC running which has references to code contained in the
1311 TRACE_CODE_GC("Native module %p died, reducing dead code objects to %zu.\n",
1355 TRACE_CODE_GC("Isolate %d reporting %zu live code objects.\n", isolate->id(),
1364 for (WasmCode* code : live_code) current_gc_info_->dead_code.erase(code);
1418 bool WasmEngine::AddPotentiallyDeadCode(WasmCode* code) {
1420 auto it = native_modules_.find(code->native_module());
1423 if (info->dead_code.count(code)) return false; // Code is already dead.
1424 auto added = info->potentially_dead_code.insert(code);
1426 new_potentially_dead_code_size_ += code->instructions().size();
1428 // Trigger a GC if 64kB plus 10% of committed code are potentially dead.
1469 TRACE_CODE_GC("Freeing %zu code object%s of module %p.\n", code_vec.size(),
1471 for (WasmCode* code : code_vec) {
1472 DCHECK_EQ(1, info->dead_code.count(code));
1473 info->dead_code.erase(code);
1566 // Add all potentially dead code to this GC, and trigger a GC task in each
1582 for (WasmCode* code : info->potentially_dead_code) {
1583 current_gc_info_->dead_code.insert(code);
1587 "Starting GC (nr %d). Number of potentially dead code objects: %zu\n",
1605 "Remaining dead code objects: %zu; outstanding isolates: %zu.\n",
1612 // All remaining code in {current_gc_info->dead_code} is really dead.
1613 // Move it from the set of potentially dead code to the set of dead code,
1617 for (WasmCode* code : current_gc_info_->dead_code) {
1618 DCHECK_EQ(1, native_modules_.count(code->native_module()));
1619 auto* native_module_info = native_modules_[code->native_module()].get();
1620 DCHECK_EQ(1, native_module_info->potentially_dead_code.count(code));
1621 native_module_info->potentially_dead_code.erase(code);
1622 DCHECK_EQ(0, native_module_info->dead_code.count(code));
1623 native_module_info->dead_code.insert(code);
1624 if (code->DecRefOnDeadCode()) {
1625 dead_code[code->native_module()].push_back(code);
1632 TRACE_CODE_GC("Found %zu dead code objects, freed %zu.\n",