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

Side by Side Diff: src/runtime/runtime-test.cc

Issue 2964943002: [wasm] Introduce instance types for WebAssembly.* objects. (Closed)
Patch Set: Address rossberg comments. Created 3 years, 5 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
« no previous file with comments | « src/objects-printer.cc ('k') | src/runtime/runtime-wasm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/assembler-inl.h" 10 #include "src/assembler-inl.h"
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 857
858 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION 858 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
859 859
860 860
861 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { 861 RUNTIME_FUNCTION(Runtime_SpeciesProtector) {
862 SealHandleScope shs(isolate); 862 SealHandleScope shs(isolate);
863 DCHECK_EQ(0, args.length()); 863 DCHECK_EQ(0, args.length());
864 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); 864 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact());
865 } 865 }
866 866
867 #define CONVERT_ARG_HANDLE_CHECKED_2(Type, name, index) \
868 CHECK(Type::Is##Type(args[index])); \
869 Handle<Type> name = args.at<Type>(index);
870
871 // Take a compiled wasm module, serialize it and copy the buffer into an array 867 // Take a compiled wasm module, serialize it and copy the buffer into an array
872 // buffer, which is then returned. 868 // buffer, which is then returned.
873 RUNTIME_FUNCTION(Runtime_SerializeWasmModule) { 869 RUNTIME_FUNCTION(Runtime_SerializeWasmModule) {
874 HandleScope shs(isolate); 870 HandleScope shs(isolate);
875 DCHECK_EQ(1, args.length()); 871 DCHECK_EQ(1, args.length());
876 CONVERT_ARG_HANDLE_CHECKED_2(WasmModuleObject, module_obj, 0); 872 CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0);
877 873
878 Handle<WasmCompiledModule> orig(module_obj->compiled_module()); 874 Handle<WasmCompiledModule> orig(module_obj->compiled_module());
879 std::unique_ptr<ScriptData> data = 875 std::unique_ptr<ScriptData> data =
880 WasmCompiledModuleSerializer::SerializeWasmModule(isolate, orig); 876 WasmCompiledModuleSerializer::SerializeWasmModule(isolate, orig);
881 void* buff = isolate->array_buffer_allocator()->Allocate(data->length()); 877 void* buff = isolate->array_buffer_allocator()->Allocate(data->length());
882 Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer(); 878 Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer();
883 JSArrayBuffer::Setup(ret, isolate, false, buff, data->length()); 879 JSArrayBuffer::Setup(ret, isolate, false, buff, data->length());
884 memcpy(buff, data->data(), data->length()); 880 memcpy(buff, data->data(), data->length());
885 return *ret; 881 return *ret;
886 } 882 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 if (!maybe_compiled_module.ToHandle(&compiled_module)) { 914 if (!maybe_compiled_module.ToHandle(&compiled_module)) {
919 return isolate->heap()->undefined_value(); 915 return isolate->heap()->undefined_value();
920 } 916 }
921 return *WasmModuleObject::New( 917 return *WasmModuleObject::New(
922 isolate, Handle<WasmCompiledModule>::cast(compiled_module)); 918 isolate, Handle<WasmCompiledModule>::cast(compiled_module));
923 } 919 }
924 920
925 RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) { 921 RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) {
926 HandleScope shs(isolate); 922 HandleScope shs(isolate);
927 DCHECK_EQ(2, args.length()); 923 DCHECK_EQ(2, args.length());
928 CONVERT_ARG_HANDLE_CHECKED_2(WasmModuleObject, module_obj, 0); 924 CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0);
929 CONVERT_ARG_HANDLE_CHECKED(Smi, instance_count, 1); 925 CONVERT_ARG_HANDLE_CHECKED(Smi, instance_count, 1);
930 wasm::testing::ValidateInstancesChain(isolate, module_obj, 926 wasm::testing::ValidateInstancesChain(isolate, module_obj,
931 instance_count->value()); 927 instance_count->value());
932 return isolate->heap()->ToBoolean(true); 928 return isolate->heap()->ToBoolean(true);
933 } 929 }
934 930
935 RUNTIME_FUNCTION(Runtime_ValidateWasmModuleState) { 931 RUNTIME_FUNCTION(Runtime_ValidateWasmModuleState) {
936 HandleScope shs(isolate); 932 HandleScope shs(isolate);
937 DCHECK_EQ(1, args.length()); 933 DCHECK_EQ(1, args.length());
938 CONVERT_ARG_HANDLE_CHECKED_2(WasmModuleObject, module_obj, 0); 934 CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0);
939 wasm::testing::ValidateModuleState(isolate, module_obj); 935 wasm::testing::ValidateModuleState(isolate, module_obj);
940 return isolate->heap()->ToBoolean(true); 936 return isolate->heap()->ToBoolean(true);
941 } 937 }
942 938
943 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) { 939 RUNTIME_FUNCTION(Runtime_ValidateWasmOrphanedInstance) {
944 HandleScope shs(isolate); 940 HandleScope shs(isolate);
945 DCHECK_EQ(1, args.length()); 941 DCHECK_EQ(1, args.length());
946 CONVERT_ARG_HANDLE_CHECKED_2(WasmInstanceObject, instance, 0); 942 CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 0);
947 wasm::testing::ValidateOrphanedInstance(isolate, instance); 943 wasm::testing::ValidateOrphanedInstance(isolate, instance);
948 return isolate->heap()->ToBoolean(true); 944 return isolate->heap()->ToBoolean(true);
949 } 945 }
950 946
951 RUNTIME_FUNCTION(Runtime_HeapObjectVerify) { 947 RUNTIME_FUNCTION(Runtime_HeapObjectVerify) {
952 HandleScope shs(isolate); 948 HandleScope shs(isolate);
953 DCHECK_EQ(1, args.length()); 949 DCHECK_EQ(1, args.length());
954 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 950 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
955 #ifdef VERIFY_HEAP 951 #ifdef VERIFY_HEAP
956 object->ObjectVerify(); 952 object->ObjectVerify();
957 #else 953 #else
958 CHECK(object->IsObject()); 954 CHECK(object->IsObject());
959 if (object->IsHeapObject()) { 955 if (object->IsHeapObject()) {
960 CHECK(HeapObject::cast(*object)->map()->IsMap()); 956 CHECK(HeapObject::cast(*object)->map()->IsMap());
961 } else { 957 } else {
962 CHECK(object->IsSmi()); 958 CHECK(object->IsSmi());
963 } 959 }
964 #endif 960 #endif
965 return isolate->heap()->ToBoolean(true); 961 return isolate->heap()->ToBoolean(true);
966 } 962 }
967 963
968 RUNTIME_FUNCTION(Runtime_WasmNumInterpretedCalls) { 964 RUNTIME_FUNCTION(Runtime_WasmNumInterpretedCalls) {
969 DCHECK_EQ(1, args.length()); 965 DCHECK_EQ(1, args.length());
970 HandleScope scope(isolate); 966 HandleScope scope(isolate);
971 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); 967 CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 0);
972 CHECK(WasmInstanceObject::IsWasmInstanceObject(*instance_obj));
973 Handle<WasmInstanceObject> instance =
974 Handle<WasmInstanceObject>::cast(instance_obj);
975 if (!instance->has_debug_info()) return 0; 968 if (!instance->has_debug_info()) return 0;
976 uint64_t num = instance->debug_info()->NumInterpretedCalls(); 969 uint64_t num = instance->debug_info()->NumInterpretedCalls();
977 return *isolate->factory()->NewNumberFromSize(static_cast<size_t>(num)); 970 return *isolate->factory()->NewNumberFromSize(static_cast<size_t>(num));
978 } 971 }
979 972
980 RUNTIME_FUNCTION(Runtime_RedirectToWasmInterpreter) { 973 RUNTIME_FUNCTION(Runtime_RedirectToWasmInterpreter) {
981 DCHECK_EQ(2, args.length()); 974 DCHECK_EQ(2, args.length());
982 HandleScope scope(isolate); 975 HandleScope scope(isolate);
983 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); 976 CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 0);
984 CONVERT_SMI_ARG_CHECKED(function_index, 1); 977 CONVERT_SMI_ARG_CHECKED(function_index, 1);
985 CHECK(WasmInstanceObject::IsWasmInstanceObject(*instance_obj));
986 Handle<WasmInstanceObject> instance =
987 Handle<WasmInstanceObject>::cast(instance_obj);
988 Handle<WasmDebugInfo> debug_info = 978 Handle<WasmDebugInfo> debug_info =
989 WasmInstanceObject::GetOrCreateDebugInfo(instance); 979 WasmInstanceObject::GetOrCreateDebugInfo(instance);
990 WasmDebugInfo::RedirectToInterpreter(debug_info, 980 WasmDebugInfo::RedirectToInterpreter(debug_info,
991 Vector<int>(&function_index, 1)); 981 Vector<int>(&function_index, 1));
992 return isolate->heap()->undefined_value(); 982 return isolate->heap()->undefined_value();
993 } 983 }
994 984
995 } // namespace internal 985 } // namespace internal
996 } // namespace v8 986 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | src/runtime/runtime-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698