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/compiler-dispatcher/optimizing-compile-dispatcher.h" | 10 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 } | 657 } |
658 | 658 |
659 | 659 |
660 RUNTIME_FUNCTION(Runtime_InNewSpace) { | 660 RUNTIME_FUNCTION(Runtime_InNewSpace) { |
661 SealHandleScope shs(isolate); | 661 SealHandleScope shs(isolate); |
662 DCHECK(args.length() == 1); | 662 DCHECK(args.length() == 1); |
663 CONVERT_ARG_CHECKED(Object, obj, 0); | 663 CONVERT_ARG_CHECKED(Object, obj, 0); |
664 return isolate->heap()->ToBoolean(isolate->heap()->InNewSpace(obj)); | 664 return isolate->heap()->ToBoolean(isolate->heap()->InNewSpace(obj)); |
665 } | 665 } |
666 | 666 |
| 667 static bool IsAsmWasmCode(Isolate* isolate, Handle<JSFunction> function) { |
| 668 if (!function->shared()->HasAsmWasmData()) { |
| 669 // Doesn't have wasm data. |
| 670 return false; |
| 671 } |
| 672 if (function->shared()->code() != |
| 673 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { |
| 674 // Hasn't been compiled yet. |
| 675 return false; |
| 676 } |
| 677 return true; |
| 678 } |
| 679 |
667 RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { | 680 RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { |
668 SealHandleScope shs(isolate); | 681 SealHandleScope shs(isolate); |
669 DCHECK(args.length() == 1); | 682 DCHECK(args.length() == 1); |
670 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 683 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 684 // TODO(mstarzinger): --always-opt should still allow asm.js->wasm, |
| 685 // but currently does not. For now, pretend asm.js->wasm is on for |
| 686 // this case. Be more accurate once this is corrected. |
| 687 return isolate->heap()->ToBoolean( |
| 688 ((FLAG_always_opt || FLAG_prepare_always_opt) && FLAG_validate_asm) || |
| 689 IsAsmWasmCode(isolate, function)); |
| 690 } |
671 | 691 |
672 if (!function->shared()->HasAsmWasmData()) { | 692 RUNTIME_FUNCTION(Runtime_IsNotAsmWasmCode) { |
673 // Doesn't have wasm data. | 693 SealHandleScope shs(isolate); |
674 return isolate->heap()->ToBoolean(false); | 694 DCHECK(args.length() == 1); |
675 } | 695 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
676 if (function->shared()->code() != | 696 return isolate->heap()->ToBoolean(!IsAsmWasmCode(isolate, function)); |
677 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { | |
678 // Hasn't been compiled yet. | |
679 return isolate->heap()->ToBoolean(false); | |
680 } | |
681 return isolate->heap()->ToBoolean(true); | |
682 } | 697 } |
683 | 698 |
684 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 699 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
685 RUNTIME_FUNCTION(Runtime_Has##Name) { \ | 700 RUNTIME_FUNCTION(Runtime_Has##Name) { \ |
686 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 701 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
687 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 702 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
688 } | 703 } |
689 | 704 |
690 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) | 705 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) |
691 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) | 706 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 WasmCompiledModuleSerializer::DeserializeWasmModule(isolate, &sc); | 766 WasmCompiledModuleSerializer::DeserializeWasmModule(isolate, &sc); |
752 Handle<FixedArray> compiled_module; | 767 Handle<FixedArray> compiled_module; |
753 if (!maybe_compiled_module.ToHandle(&compiled_module)) { | 768 if (!maybe_compiled_module.ToHandle(&compiled_module)) { |
754 return isolate->heap()->undefined_value(); | 769 return isolate->heap()->undefined_value(); |
755 } | 770 } |
756 return *wasm::CreateCompiledModuleObject(isolate, compiled_module); | 771 return *wasm::CreateCompiledModuleObject(isolate, compiled_module); |
757 } | 772 } |
758 | 773 |
759 } // namespace internal | 774 } // namespace internal |
760 } // namespace v8 | 775 } // namespace v8 |
OLD | NEW |