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

Side by Side Diff: src/runtime/runtime-test.cc

Issue 2204703002: [wasm] Get rid of extra wrappers when import another wasm export (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make test case code more clean Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 DCHECK(args.length() == 1); 275 DCHECK(args.length() == 1);
276 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 276 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
277 function->ClearTypeFeedbackInfo(); 277 function->ClearTypeFeedbackInfo();
278 Code* unoptimized = function->shared()->code(); 278 Code* unoptimized = function->shared()->code();
279 if (unoptimized->kind() == Code::FUNCTION) { 279 if (unoptimized->kind() == Code::FUNCTION) {
280 unoptimized->ClearInlineCaches(); 280 unoptimized->ClearInlineCaches();
281 } 281 }
282 return isolate->heap()->undefined_value(); 282 return isolate->heap()->undefined_value();
283 } 283 }
284 284
285 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
286 // This only supports the case where the function being exported
287 // calls an intermediate function, and the intermediate function
288 // calls exactly one imported function
289 HandleScope scope(isolate);
290 CHECK(args.length() == 2);
291 // It takes two parameters, the first one is the JSFunction,
292 // The second one is the type
293 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
294 // If type is 0, it means that it is supposed to be a direct call into a WASM
295 // function
296 // If type is 1, it means that it is supposed to have wrappers
297 CONVERT_ARG_HANDLE_CHECKED(Smi, type, 1);
298 Handle<Code> export_code = handle(function->code());
299 CHECK(export_code->kind() == Code::JS_TO_WASM_FUNCTION);
300 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
301 // check the type of the $export_fct
302 Handle<Code> export_fct;
303 int count = 0;
304 for (RelocIterator it(*export_code, mask); !it.done(); it.next()) {
305 RelocInfo* rinfo = it.rinfo();
306 Address target_address = rinfo->target_address();
307 Code* target = Code::GetCodeFromTargetAddress(target_address);
308 if (target->kind() == Code::WASM_FUNCTION) {
309 ++count;
310 export_fct = handle(target);
311 }
312 }
313 CHECK(count == 1);
314 // check the type of the intermediate_fct
315 Handle<Code> intermediate_fct;
316 count = 0;
317 for (RelocIterator it(*export_fct, mask); !it.done(); it.next()) {
318 RelocInfo* rinfo = it.rinfo();
319 Address target_address = rinfo->target_address();
320 Code* target = Code::GetCodeFromTargetAddress(target_address);
321 if (target->kind() == Code::WASM_FUNCTION) {
322 ++count;
323 intermediate_fct = handle(target);
324 }
325 }
326 CHECK(count == 1);
327 // check the type of the imported exported function, it should be also a WASM
328 // function in our case
329 Handle<Code> imported_fct;
330 Code::Kind target_kind;
331 if (type->value() == 0) {
332 target_kind = Code::WASM_FUNCTION;
333 } else if (type->value() == 1) {
334 target_kind = Code::WASM_TO_JS_FUNCTION;
335 }
336 count = 0;
337 for (RelocIterator it(*intermediate_fct, mask); !it.done(); it.next()) {
338 RelocInfo* rinfo = it.rinfo();
339 Address target_address = rinfo->target_address();
340 Code* target = Code::GetCodeFromTargetAddress(target_address);
341 if (target->kind() == target_kind) {
342 ++count;
343 imported_fct = handle(target);
344 }
345 }
346 CHECK_LE(count, 1);
347 return isolate->heap()->ToBoolean(count == 1);
348 }
285 349
286 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { 350 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
287 HandleScope scope(isolate); 351 HandleScope scope(isolate);
288 DCHECK(args.length() == 0); 352 DCHECK(args.length() == 0);
289 isolate->heap()->NotifyContextDisposed(true); 353 isolate->heap()->NotifyContextDisposed(true);
290 return isolate->heap()->undefined_value(); 354 return isolate->heap()->undefined_value();
291 } 355 }
292 356
293 357
294 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { 358 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 638
575 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { 639 RUNTIME_FUNCTION(Runtime_SpeciesProtector) {
576 SealHandleScope shs(isolate); 640 SealHandleScope shs(isolate);
577 DCHECK_EQ(0, args.length()); 641 DCHECK_EQ(0, args.length());
578 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); 642 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact());
579 } 643 }
580 644
581 645
582 } // namespace internal 646 } // namespace internal
583 } // namespace v8 647 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698