Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 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 if (export_code->kind() != Code::JS_TO_WASM_FUNCTION) { | |
|
Mircea Trofin
2016/08/04 18:21:08
actually, this is a fine place to fail (CHECK). Th
Chen
2016/08/04 20:05:07
Done.
| |
| 297 return isolate->heap()->ToBoolean(false); | |
| 298 } | |
| 299 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | |
| 300 // check the type of the $export_fct | |
| 301 Handle<Code> export_fct; | |
| 302 int count = 0; | |
| 303 for (RelocIterator it(*export_code, mask); !it.done(); it.next()) { | |
| 304 RelocInfo* rinfo = it.rinfo(); | |
| 305 Address target_address = rinfo->target_address(); | |
| 306 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
| 307 if (target->kind() == Code::WASM_FUNCTION) { | |
| 308 ++count; | |
| 309 export_fct = handle(target); | |
| 310 } | |
| 311 } | |
| 312 if (count != 1) { | |
|
Mircea Trofin
2016/08/04 18:21:08
This is also a CHECK - an export is expected to wr
Chen
2016/08/04 20:05:07
Done.
| |
| 313 return isolate->heap()->ToBoolean(false); | |
| 314 } | |
| 315 // check the type of the $increment | |
|
Mircea Trofin
2016/08/04 18:21:08
$increment?
Chen
2016/08/04 20:05:07
Done.
| |
| 316 Handle<Code> wrapped_fct; | |
| 317 count = 0; | |
| 318 for (RelocIterator it(*export_fct, mask); !it.done(); it.next()) { | |
| 319 RelocInfo* rinfo = it.rinfo(); | |
| 320 Address target_address = rinfo->target_address(); | |
| 321 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
| 322 if (target->kind() == Code::WASM_FUNCTION) { | |
| 323 ++count; | |
| 324 wrapped_fct = handle(target); | |
| 325 } | |
| 326 } | |
| 327 if (count != 1) { | |
|
Mircea Trofin
2016/08/04 18:21:08
also a CHECK
Chen
2016/08/04 20:05:07
Done.
| |
| 328 return isolate->heap()->ToBoolean(false); | |
| 329 } | |
| 330 // check the type of the imported exported function, it should be also a WASM | |
| 331 // function in our case | |
| 332 Handle<Code> imported_fct; | |
| 333 Code::Kind target_kind; | |
| 334 if (type->value() == 0) { | |
| 335 target_kind = Code::WASM_FUNCTION; | |
| 336 } else if (type->value() == 1) { | |
| 337 target_kind = Code::WASM_TO_JS_FUNCTION; | |
| 338 } | |
| 339 count = 0; | |
| 340 for (RelocIterator it(*wrapped_fct, mask); !it.done(); it.next()) { | |
| 341 RelocInfo* rinfo = it.rinfo(); | |
| 342 Address target_address = rinfo->target_address(); | |
| 343 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
| 344 if (target->kind() == target_kind) { | |
| 345 ++count; | |
| 346 imported_fct = handle(target); | |
| 347 } | |
| 348 } | |
|
Mircea Trofin
2016/08/04 18:21:08
CHECK_LE(count, 1)
Chen
2016/08/04 20:05:07
Done.
| |
| 349 if (count != 1) { | |
| 350 return isolate->heap()->ToBoolean(false); | |
| 351 } | |
| 352 return isolate->heap()->ToBoolean(true); | |
| 353 } | |
| 285 | 354 |
| 286 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { | 355 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { |
| 287 HandleScope scope(isolate); | 356 HandleScope scope(isolate); |
| 288 DCHECK(args.length() == 0); | 357 DCHECK(args.length() == 0); |
| 289 isolate->heap()->NotifyContextDisposed(true); | 358 isolate->heap()->NotifyContextDisposed(true); |
| 290 return isolate->heap()->undefined_value(); | 359 return isolate->heap()->undefined_value(); |
| 291 } | 360 } |
| 292 | 361 |
| 293 | 362 |
| 294 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { | 363 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 | 643 |
| 575 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { | 644 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { |
| 576 SealHandleScope shs(isolate); | 645 SealHandleScope shs(isolate); |
| 577 DCHECK_EQ(0, args.length()); | 646 DCHECK_EQ(0, args.length()); |
| 578 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); | 647 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); |
| 579 } | 648 } |
| 580 | 649 |
| 581 | 650 |
| 582 } // namespace internal | 651 } // namespace internal |
| 583 } // namespace v8 | 652 } // namespace v8 |
| OLD | NEW |