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

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: Made code more clean according to code reviews 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
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_CheckWasmWrapperElison) {
Mircea Trofin 2016/08/04 00:51:28 typo (...Elison => ...Elision)
Chen 2016/08/04 17:21:53 Done.
286 // This only supports the case where the function being exported
287 // calls exactly one import
288 HandleScope scope(isolate);
289 DCHECK(args.length() == 2);
290 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
291 // If type is 0, it means that it is supposed to be a direct call to WASM
292 // function
293 // If type is 1, it means that it is supposed to have wrappers
294 CONVERT_ARG_HANDLE_CHECKED(Smi, type, 1);
295 Handle<Code> export_code = handle(function->code());
296 DCHECK(export_code->kind() == Code::JS_TO_WASM_FUNCTION);
297 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
298 // check the type of the $export_fct
299 Handle<Code> export_fct;
300 int count = 0;
301 for (RelocIterator it(*export_code, mask); !it.done(); it.next()) {
302 RelocInfo* rinfo = it.rinfo();
303 Address target_address = rinfo->target_address();
304 Code* target = Code::GetCodeFromTargetAddress(target_address);
305 if (target->kind() == Code::WASM_FUNCTION) {
306 ++count;
307 export_fct = handle(target);
308 }
309 }
310 DCHECK(count == 1);
311 // check the type of the $increment
312 Handle<Code> wrapped_fct;
313 count = 0;
314 for (RelocIterator it(*export_fct, mask); !it.done(); it.next()) {
315 RelocInfo* rinfo = it.rinfo();
316 Address target_address = rinfo->target_address();
317 Code* target = Code::GetCodeFromTargetAddress(target_address);
318 if (target->kind() == Code::WASM_FUNCTION) {
319 ++count;
320 wrapped_fct = handle(target);
321 }
322 }
323 DCHECK(count == 1);
324 // check the type of the imported exported function, it should be also a WASM
325 // function in our case
326 Handle<Code> imported_fct;
327 Code::Kind target_kind;
328 if (type->value() == 0) {
329 target_kind = Code::WASM_FUNCTION;
330 } else if (type->value() == 1) {
331 target_kind = Code::WASM_TO_JS_FUNCTION;
332 }
333 count = 0;
334 for (RelocIterator it(*wrapped_fct, mask); !it.done(); it.next()) {
335 RelocInfo* rinfo = it.rinfo();
336 Address target_address = rinfo->target_address();
337 Code* target = Code::GetCodeFromTargetAddress(target_address);
338 if (target->kind() == target_kind) {
339 ++count;
340 imported_fct = handle(target);
341 }
342 }
343 DCHECK(count == 1);
344 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.
345 }
285 346
286 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { 347 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
287 HandleScope scope(isolate); 348 HandleScope scope(isolate);
288 DCHECK(args.length() == 0); 349 DCHECK(args.length() == 0);
289 isolate->heap()->NotifyContextDisposed(true); 350 isolate->heap()->NotifyContextDisposed(true);
290 return isolate->heap()->undefined_value(); 351 return isolate->heap()->undefined_value();
291 } 352 }
292 353
293 354
294 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { 355 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 635
575 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { 636 RUNTIME_FUNCTION(Runtime_SpeciesProtector) {
576 SealHandleScope shs(isolate); 637 SealHandleScope shs(isolate);
577 DCHECK_EQ(0, args.length()); 638 DCHECK_EQ(0, args.length());
578 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); 639 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact());
579 } 640 }
580 641
581 642
582 } // namespace internal 643 } // namespace internal
583 } // namespace v8 644 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698