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 namespace { | |
681 | |
682 bool IsAsmWasmCode(Isolate* isolate, Handle<JSFunction> function) { | |
683 if (!function->shared()->HasAsmWasmData()) { | |
684 // Doesn't have wasm data. | |
685 return false; | |
686 } | |
687 if (function->shared()->code() != | |
688 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { | |
689 // Hasn't been compiled yet. | |
690 return false; | |
691 } | |
692 return true; | |
693 } | |
694 | |
695 } // namespace | |
696 | |
697 RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { | 680 RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { |
698 SealHandleScope shs(isolate); | 681 SealHandleScope shs(isolate); |
699 DCHECK_EQ(1, args.length()); | 682 DCHECK_EQ(1, args.length()); |
700 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 683 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
701 return isolate->heap()->ToBoolean(IsAsmWasmCode(isolate, function)); | 684 if (!function->shared()->HasAsmWasmData()) { |
| 685 // Doesn't have wasm data. |
| 686 return isolate->heap()->false_value(); |
| 687 } |
| 688 if (function->shared()->code() != |
| 689 isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { |
| 690 // Hasn't been compiled yet. |
| 691 return isolate->heap()->false_value(); |
| 692 } |
| 693 return isolate->heap()->true_value(); |
702 } | 694 } |
703 | 695 |
704 RUNTIME_FUNCTION(Runtime_IsNotAsmWasmCode) { | |
705 SealHandleScope shs(isolate); | |
706 DCHECK_EQ(1, args.length()); | |
707 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | |
708 return isolate->heap()->ToBoolean(!IsAsmWasmCode(isolate, function)); | |
709 } | |
710 | 696 |
711 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 697 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
712 RUNTIME_FUNCTION(Runtime_Has##Name) { \ | 698 RUNTIME_FUNCTION(Runtime_Has##Name) { \ |
713 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 699 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
714 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 700 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
715 } | 701 } |
716 | 702 |
717 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) | 703 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) |
718 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) | 704 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) |
719 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) | 705 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { | 810 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { |
825 HandleScope shs(isolate); | 811 HandleScope shs(isolate); |
826 DCHECK(args.length() == 1); | 812 DCHECK(args.length() == 1); |
827 CONVERT_ARG_HANDLE_CHECKED_2(WasmInstanceObject, instance, 0); | 813 CONVERT_ARG_HANDLE_CHECKED_2(WasmInstanceObject, instance, 0); |
828 wasm::testing::ValidateOrphanedInstance(isolate, instance); | 814 wasm::testing::ValidateOrphanedInstance(isolate, instance); |
829 return isolate->heap()->ToBoolean(true); | 815 return isolate->heap()->ToBoolean(true); |
830 } | 816 } |
831 | 817 |
832 } // namespace internal | 818 } // namespace internal |
833 } // namespace v8 | 819 } // namespace v8 |
OLD | NEW |