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

Unified Diff: src/wasm/wasm-module.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 | « src/wasm/wasm-code-specialization.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 75a556971d521f7b515201b551598f77fa4c9364..11f9267b21a8bf05c6f495082dd80d8f564eb55d 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -860,24 +860,28 @@ static WasmFunction* GetWasmFunctionForImportWrapper(Isolate* isolate,
return nullptr;
}
-static Handle<Code> UnwrapImportWrapper(Handle<Object> target) {
- Handle<JSFunction> func = Handle<JSFunction>::cast(target);
+static Handle<Code> UnwrapImportWrapper(Handle<Object> import_wrapper) {
+ Handle<JSFunction> func = Handle<JSFunction>::cast(import_wrapper);
Handle<Code> export_wrapper_code = handle(func->code());
- int found = 0;
int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
- Handle<Code> code;
- for (RelocIterator it(*export_wrapper_code, mask); !it.done(); it.next()) {
- RelocInfo* rinfo = it.rinfo();
- Address target_address = rinfo->target_address();
- Code* target = Code::GetCodeFromTargetAddress(target_address);
- if (target->kind() == Code::WASM_FUNCTION ||
- target->kind() == Code::WASM_TO_JS_FUNCTION) {
- ++found;
- code = handle(target);
- }
- }
- DCHECK_EQ(1, found);
- return code;
+ for (RelocIterator it(*export_wrapper_code, mask);; it.next()) {
+ DCHECK(!it.done());
+ Code* target = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
+ if (target->kind() != Code::WASM_FUNCTION &&
+ target->kind() != Code::WASM_TO_JS_FUNCTION)
+ continue;
+// There should only be this one call to wasm code.
+#ifdef DEBUG
+ for (it.next(); !it.done(); it.next()) {
+ Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
+ DCHECK(code->kind() != Code::WASM_FUNCTION &&
+ code->kind() != Code::WASM_TO_JS_FUNCTION);
+ }
+#endif
+ return handle(target);
+ }
+ UNREACHABLE();
+ return Handle<Code>::null();
}
static Handle<Code> CompileImportWrapper(Isolate* isolate, int index,
« no previous file with comments | « src/wasm/wasm-code-specialization.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698