Chromium Code Reviews| Index: src/runtime/runtime-test.cc |
| diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc |
| index 2232b190599a2b1a3025ea72bb44ef23596130ce..e689705ecd4597c18a1d15091e700d5d5b588010 100644 |
| --- a/src/runtime/runtime-test.cc |
| +++ b/src/runtime/runtime-test.cc |
| @@ -282,6 +282,67 @@ RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { |
| return isolate->heap()->undefined_value(); |
| } |
| +RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElison) { |
|
Mircea Trofin
2016/08/04 00:51:28
typo (...Elison => ...Elision)
Chen
2016/08/04 17:21:53
Done.
|
| + // This only supports the case where the function being exported |
| + // calls exactly one import |
| + HandleScope scope(isolate); |
| + DCHECK(args.length() == 2); |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| + // If type is 0, it means that it is supposed to be a direct call to WASM |
| + // function |
| + // If type is 1, it means that it is supposed to have wrappers |
| + CONVERT_ARG_HANDLE_CHECKED(Smi, type, 1); |
| + Handle<Code> export_code = handle(function->code()); |
| + DCHECK(export_code->kind() == Code::JS_TO_WASM_FUNCTION); |
| + int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
| + // check the type of the $export_fct |
| + Handle<Code> export_fct; |
| + int count = 0; |
| + for (RelocIterator it(*export_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) { |
| + ++count; |
| + export_fct = handle(target); |
| + } |
| + } |
| + DCHECK(count == 1); |
| + // check the type of the $increment |
| + Handle<Code> wrapped_fct; |
| + count = 0; |
| + for (RelocIterator it(*export_fct, 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) { |
| + ++count; |
| + wrapped_fct = handle(target); |
| + } |
| + } |
| + DCHECK(count == 1); |
| + // check the type of the imported exported function, it should be also a WASM |
| + // function in our case |
| + Handle<Code> imported_fct; |
| + Code::Kind target_kind; |
| + if (type->value() == 0) { |
| + target_kind = Code::WASM_FUNCTION; |
| + } else if (type->value() == 1) { |
| + target_kind = Code::WASM_TO_JS_FUNCTION; |
| + } |
| + count = 0; |
| + for (RelocIterator it(*wrapped_fct, mask); !it.done(); it.next()) { |
| + RelocInfo* rinfo = it.rinfo(); |
| + Address target_address = rinfo->target_address(); |
| + Code* target = Code::GetCodeFromTargetAddress(target_address); |
| + if (target->kind() == target_kind) { |
| + ++count; |
| + imported_fct = handle(target); |
| + } |
| + } |
| + DCHECK(count == 1); |
| + return isolate->heap()->undefined_value(); |
|
Mircea Trofin
2016/08/04 00:51:28
return true/false, otherwise you'll bring down the
Chen
2016/08/04 17:21:53
Done.
|
| +} |
| RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { |
| HandleScope scope(isolate); |