Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: src/wasm/wasm-code-specialization.cc

Issue 2717973003: [wasm] Exit loop once wasm code in JS_TO_WASM is found (Closed)
Patch Set: Address comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-code-specialization.cc
diff --git a/src/wasm/wasm-code-specialization.cc b/src/wasm/wasm-code-specialization.cc
index d9d7c164cf1d4e14cd0999a7218820288cea2f95..633c0f056ec6ac4cf48a0ff3930ec260311df9a7 100644
--- a/src/wasm/wasm-code-specialization.cc
+++ b/src/wasm/wasm-code-specialization.cc
@@ -56,6 +56,14 @@ class PatchDirectCallsHelper {
const byte* func_bytes;
};
+bool IsAtWasmDirectCallTarget(RelocIterator& it) {
+ DCHECK(RelocInfo::IsCodeTarget(it.rinfo()->rmode()));
+ Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
+ return code->kind() == Code::WASM_FUNCTION ||
+ code->kind() == Code::WASM_TO_JS_FUNCTION ||
+ code->builtin_index() == Builtins::kIllegal;
+}
+
} // namespace
CodeSpecialization::CodeSpecialization(Isolate* isolate, Zone* zone)
@@ -131,26 +139,20 @@ bool CodeSpecialization::ApplyToWholeInstance(
Code* export_wrapper = Code::cast(code_table->get(func_index));
DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, export_wrapper->kind());
// There must be exactly one call to WASM_FUNCTION or WASM_TO_JS_FUNCTION.
- int num_wasm_calls = 0;
for (RelocIterator it(export_wrapper,
RelocInfo::ModeMask(RelocInfo::CODE_TARGET));
- !it.done(); it.next()) {
- DCHECK(RelocInfo::IsCodeTarget(it.rinfo()->rmode()));
- Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
+ ; it.next()) {
+ DCHECK(!it.done());
// Ignore calls to other builtins like ToNumber.
- if (code->kind() != Code::WASM_FUNCTION &&
- code->kind() != Code::WASM_TO_JS_FUNCTION &&
- code->builtin_index() != Builtins::kIllegal)
- continue;
- ++num_wasm_calls;
+ if (!IsAtWasmDirectCallTarget(it)) continue;
Code* new_code = Code::cast(code_table->get(exp.index));
DCHECK(new_code->kind() == Code::WASM_FUNCTION ||
new_code->kind() == Code::WASM_TO_JS_FUNCTION);
it.rinfo()->set_target_address(new_code->instruction_start(),
UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH);
- changed = true;
+ break;
}
- DCHECK_EQ(1, num_wasm_calls);
+ changed = true;
func_index++;
}
DCHECK_EQ(code_table->length(), func_index);
@@ -201,13 +203,8 @@ bool CodeSpecialization::ApplyToWasmCode(Code* code,
break;
case RelocInfo::CODE_TARGET: {
DCHECK(reloc_direct_calls);
- Code* old_code =
- Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
// Skip everything which is not a wasm call (stack checks, traps, ...).
- if (old_code->kind() != Code::WASM_FUNCTION &&
- old_code->kind() != Code::WASM_TO_JS_FUNCTION &&
- old_code->builtin_index() != Builtins::kIllegal)
- continue;
+ if (!IsAtWasmDirectCallTarget(it)) continue;
// Iterate simultaneously over the relocation information and the source
// position table. For each call in the reloc info, move the source
// position iterator forward to that position to find the byte offset of
« no previous file with comments | « no previous file | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698