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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 } | 670 } |
671 | 671 |
672 | 672 |
673 RUNTIME_FUNCTION(Runtime_InNewSpace) { | 673 RUNTIME_FUNCTION(Runtime_InNewSpace) { |
674 SealHandleScope shs(isolate); | 674 SealHandleScope shs(isolate); |
675 DCHECK(args.length() == 1); | 675 DCHECK(args.length() == 1); |
676 CONVERT_ARG_CHECKED(Object, obj, 0); | 676 CONVERT_ARG_CHECKED(Object, obj, 0); |
677 return isolate->heap()->ToBoolean(isolate->heap()->InNewSpace(obj)); | 677 return isolate->heap()->ToBoolean(isolate->heap()->InNewSpace(obj)); |
678 } | 678 } |
679 | 679 |
680 static bool IsAsmWasmCode(Isolate* isolate, Handle<JSFunction> function) { | 680 namespace { |
| 681 |
| 682 bool IsAsmWasmCode(Isolate* isolate, Handle<JSFunction> function) { |
681 if (!function->shared()->HasAsmWasmData()) { | 683 if (!function->shared()->HasAsmWasmData()) { |
682 // Doesn't have wasm data. | 684 // Doesn't have wasm data. |
683 return false; | 685 return false; |
684 } | 686 } |
685 if (function->shared()->code() != | 687 if (function->shared()->code() != |
686 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { | 688 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { |
687 // Hasn't been compiled yet. | 689 // Hasn't been compiled yet. |
688 return false; | 690 return false; |
689 } | 691 } |
690 return true; | 692 return true; |
691 } | 693 } |
692 | 694 |
| 695 } // namespace |
| 696 |
693 RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { | 697 RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { |
694 SealHandleScope shs(isolate); | 698 SealHandleScope shs(isolate); |
695 DCHECK(args.length() == 1); | 699 DCHECK_EQ(1, args.length()); |
696 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 700 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
697 // TODO(mstarzinger): --always-opt should still allow asm.js->wasm, | 701 return isolate->heap()->ToBoolean(IsAsmWasmCode(isolate, function)); |
698 // but currently does not. For now, pretend asm.js->wasm is on for | |
699 // this case. Be more accurate once this is corrected. | |
700 return isolate->heap()->ToBoolean( | |
701 ((FLAG_always_opt || FLAG_prepare_always_opt) && FLAG_validate_asm) || | |
702 IsAsmWasmCode(isolate, function)); | |
703 } | 702 } |
704 | 703 |
705 RUNTIME_FUNCTION(Runtime_IsNotAsmWasmCode) { | 704 RUNTIME_FUNCTION(Runtime_IsNotAsmWasmCode) { |
706 SealHandleScope shs(isolate); | 705 SealHandleScope shs(isolate); |
707 DCHECK(args.length() == 1); | 706 DCHECK_EQ(1, args.length()); |
708 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 707 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
709 return isolate->heap()->ToBoolean(!IsAsmWasmCode(isolate, function)); | 708 return isolate->heap()->ToBoolean(!IsAsmWasmCode(isolate, function)); |
710 } | 709 } |
711 | 710 |
712 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 711 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
713 RUNTIME_FUNCTION(Runtime_Has##Name) { \ | 712 RUNTIME_FUNCTION(Runtime_Has##Name) { \ |
714 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 713 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
715 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 714 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
716 } | 715 } |
717 | 716 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { | 824 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { |
826 HandleScope shs(isolate); | 825 HandleScope shs(isolate); |
827 DCHECK(args.length() == 1); | 826 DCHECK(args.length() == 1); |
828 CONVERT_ARG_HANDLE_CHECKED_2(WasmInstanceObject, instance, 0); | 827 CONVERT_ARG_HANDLE_CHECKED_2(WasmInstanceObject, instance, 0); |
829 wasm::testing::ValidateOrphanedInstance(isolate, instance); | 828 wasm::testing::ValidateOrphanedInstance(isolate, instance); |
830 return isolate->heap()->ToBoolean(true); | 829 return isolate->heap()->ToBoolean(true); |
831 } | 830 } |
832 | 831 |
833 } // namespace internal | 832 } // namespace internal |
834 } // namespace v8 | 833 } // namespace v8 |
OLD | NEW |