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

Side by Side Diff: src/wasm/wasm-js.cc

Issue 2428343005: [wasm] Improve naming consistency for WASM instances. (Closed)
Patch Set: Also rename FrameArray::WasmObject Created 4 years, 2 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/wasm/wasm-debug.cc ('k') | src/wasm/wasm-module.h » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/api-natives.h" 5 #include "src/api-natives.h"
6 #include "src/api.h" 6 #include "src/api.h"
7 #include "src/asmjs/asm-js.h" 7 #include "src/asmjs/asm-js.h"
8 #include "src/asmjs/asm-typer.h" 8 #include "src/asmjs/asm-typer.h"
9 #include "src/asmjs/asm-wasm-builder.h" 9 #include "src/asmjs/asm-wasm-builder.h"
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 787
788 Handle<Symbol> memory_sym = factory->NewPrivateSymbol(); 788 Handle<Symbol> memory_sym = factory->NewPrivateSymbol();
789 context->set_wasm_memory_sym(*memory_sym); 789 context->set_wasm_memory_sym(*memory_sym);
790 790
791 // Bind the WebAssembly object. 791 // Bind the WebAssembly object.
792 Handle<String> name = v8_str(isolate, "WebAssembly"); 792 Handle<String> name = v8_str(isolate, "WebAssembly");
793 Handle<JSFunction> cons = factory->NewFunction(name); 793 Handle<JSFunction> cons = factory->NewFunction(name);
794 JSFunction::SetInstancePrototype( 794 JSFunction::SetInstancePrototype(
795 cons, Handle<Object>(context->initial_object_prototype(), isolate)); 795 cons, Handle<Object>(context->initial_object_prototype(), isolate));
796 cons->shared()->set_instance_class_name(*name); 796 cons->shared()->set_instance_class_name(*name);
797 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED); 797 Handle<JSObject> webassembly = factory->NewJSObject(cons, TENURED);
798 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM); 798 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM);
799 JSObject::AddProperty(global, name, wasm_object, attributes); 799 JSObject::AddProperty(global, name, webassembly, attributes);
800 800
801 // Setup compile 801 // Setup compile
802 InstallFunc(isolate, wasm_object, "compile", WebAssemblyCompile); 802 InstallFunc(isolate, webassembly, "compile", WebAssemblyCompile);
803 803
804 // Setup compile 804 // Setup compile
805 InstallFunc(isolate, wasm_object, "validate", WebAssemblyValidate); 805 InstallFunc(isolate, webassembly, "validate", WebAssemblyValidate);
806 806
807 // Setup Module 807 // Setup Module
808 Handle<JSFunction> module_constructor = 808 Handle<JSFunction> module_constructor =
809 InstallFunc(isolate, wasm_object, "Module", WebAssemblyModule); 809 InstallFunc(isolate, webassembly, "Module", WebAssemblyModule);
810 context->set_wasm_module_constructor(*module_constructor); 810 context->set_wasm_module_constructor(*module_constructor);
811 Handle<JSObject> module_proto = 811 Handle<JSObject> module_proto =
812 factory->NewJSObject(module_constructor, TENURED); 812 factory->NewJSObject(module_constructor, TENURED);
813 i::Handle<i::Map> map = isolate->factory()->NewMap( 813 i::Handle<i::Map> map = isolate->factory()->NewMap(
814 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize + i::kPointerSize); 814 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize + i::kPointerSize);
815 JSFunction::SetInitialMap(module_constructor, map, module_proto); 815 JSFunction::SetInitialMap(module_constructor, map, module_proto);
816 JSObject::AddProperty(module_proto, isolate->factory()->constructor_string(), 816 JSObject::AddProperty(module_proto, isolate->factory()->constructor_string(),
817 module_constructor, DONT_ENUM); 817 module_constructor, DONT_ENUM);
818 818
819 // Setup Instance 819 // Setup Instance
820 Handle<JSFunction> instance_constructor = 820 Handle<JSFunction> instance_constructor =
821 InstallFunc(isolate, wasm_object, "Instance", WebAssemblyInstance); 821 InstallFunc(isolate, webassembly, "Instance", WebAssemblyInstance);
822 context->set_wasm_instance_constructor(*instance_constructor); 822 context->set_wasm_instance_constructor(*instance_constructor);
823 823
824 // Setup Table 824 // Setup Table
825 Handle<JSFunction> table_constructor = 825 Handle<JSFunction> table_constructor =
826 InstallFunc(isolate, wasm_object, "Table", WebAssemblyTable); 826 InstallFunc(isolate, webassembly, "Table", WebAssemblyTable);
827 context->set_wasm_table_constructor(*table_constructor); 827 context->set_wasm_table_constructor(*table_constructor);
828 Handle<JSObject> table_proto = 828 Handle<JSObject> table_proto =
829 factory->NewJSObject(table_constructor, TENURED); 829 factory->NewJSObject(table_constructor, TENURED);
830 map = isolate->factory()->NewMap( 830 map = isolate->factory()->NewMap(
831 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize + 831 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize +
832 kWasmTableInternalFieldCount * i::kPointerSize); 832 kWasmTableInternalFieldCount * i::kPointerSize);
833 JSFunction::SetInitialMap(table_constructor, map, table_proto); 833 JSFunction::SetInitialMap(table_constructor, map, table_proto);
834 JSObject::AddProperty(table_proto, isolate->factory()->constructor_string(), 834 JSObject::AddProperty(table_proto, isolate->factory()->constructor_string(),
835 table_constructor, DONT_ENUM); 835 table_constructor, DONT_ENUM);
836 InstallGetter(isolate, table_proto, "length", WebAssemblyTableGetLength); 836 InstallGetter(isolate, table_proto, "length", WebAssemblyTableGetLength);
837 InstallFunc(isolate, table_proto, "grow", WebAssemblyTableGrow); 837 InstallFunc(isolate, table_proto, "grow", WebAssemblyTableGrow);
838 InstallFunc(isolate, table_proto, "get", WebAssemblyTableGet); 838 InstallFunc(isolate, table_proto, "get", WebAssemblyTableGet);
839 InstallFunc(isolate, table_proto, "set", WebAssemblyTableSet); 839 InstallFunc(isolate, table_proto, "set", WebAssemblyTableSet);
840 840
841 // Setup Memory 841 // Setup Memory
842 Handle<JSFunction> memory_constructor = 842 Handle<JSFunction> memory_constructor =
843 InstallFunc(isolate, wasm_object, "Memory", WebAssemblyMemory); 843 InstallFunc(isolate, webassembly, "Memory", WebAssemblyMemory);
844 context->set_wasm_memory_constructor(*memory_constructor); 844 context->set_wasm_memory_constructor(*memory_constructor);
845 Handle<JSObject> memory_proto = 845 Handle<JSObject> memory_proto =
846 factory->NewJSObject(memory_constructor, TENURED); 846 factory->NewJSObject(memory_constructor, TENURED);
847 map = isolate->factory()->NewMap( 847 map = isolate->factory()->NewMap(
848 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize + 848 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize +
849 kWasmMemoryInternalFieldCount * i::kPointerSize); 849 kWasmMemoryInternalFieldCount * i::kPointerSize);
850 JSFunction::SetInitialMap(memory_constructor, map, memory_proto); 850 JSFunction::SetInitialMap(memory_constructor, map, memory_proto);
851 JSObject::AddProperty(memory_proto, isolate->factory()->constructor_string(), 851 JSObject::AddProperty(memory_proto, isolate->factory()->constructor_string(),
852 memory_constructor, DONT_ENUM); 852 memory_constructor, DONT_ENUM);
853 InstallFunc(isolate, memory_proto, "grow", WebAssemblyMemoryGrow); 853 InstallFunc(isolate, memory_proto, "grow", WebAssemblyMemoryGrow);
854 InstallGetter(isolate, memory_proto, "buffer", WebAssemblyMemoryGetBuffer); 854 InstallGetter(isolate, memory_proto, "buffer", WebAssemblyMemoryGetBuffer);
855 855
856 // Setup errors 856 // Setup errors
857 attributes = static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 857 attributes = static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
858 Handle<JSFunction> compile_error( 858 Handle<JSFunction> compile_error(
859 isolate->native_context()->wasm_compile_error_function()); 859 isolate->native_context()->wasm_compile_error_function());
860 JSObject::AddProperty(wasm_object, isolate->factory()->CompileError_string(), 860 JSObject::AddProperty(webassembly, isolate->factory()->CompileError_string(),
861 compile_error, attributes); 861 compile_error, attributes);
862 Handle<JSFunction> runtime_error( 862 Handle<JSFunction> runtime_error(
863 isolate->native_context()->wasm_runtime_error_function()); 863 isolate->native_context()->wasm_runtime_error_function());
864 JSObject::AddProperty(wasm_object, isolate->factory()->RuntimeError_string(), 864 JSObject::AddProperty(webassembly, isolate->factory()->RuntimeError_string(),
865 runtime_error, attributes); 865 runtime_error, attributes);
866 } 866 }
867 867
868 void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) { 868 void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
869 if (!FLAG_expose_wasm && !FLAG_validate_asm) { 869 if (!FLAG_expose_wasm && !FLAG_validate_asm) {
870 return; 870 return;
871 } 871 }
872 872
873 Factory* factory = isolate->factory(); 873 Factory* factory = isolate->factory();
874 874
875 // Setup wasm function map. 875 // Setup wasm function map.
876 Handle<Context> context(global->native_context(), isolate); 876 Handle<Context> context(global->native_context(), isolate);
877 InstallWasmMapsIfNeeded(isolate, context); 877 InstallWasmMapsIfNeeded(isolate, context);
878 878
879 if (!FLAG_expose_wasm) { 879 if (!FLAG_expose_wasm) {
880 return; 880 return;
881 } 881 }
882 882
883 // Bind the experimental WASM object. 883 // Bind the experimental "Wasm" object.
884 // TODO(rossberg, titzer): remove once it's no longer needed. 884 // TODO(rossberg, titzer): remove once it's no longer needed.
885 { 885 {
886 Handle<String> name = v8_str(isolate, "Wasm"); 886 Handle<String> name = v8_str(isolate, "Wasm");
887 Handle<JSFunction> cons = factory->NewFunction(name); 887 Handle<JSFunction> cons = factory->NewFunction(name);
888 JSFunction::SetInstancePrototype( 888 JSFunction::SetInstancePrototype(
889 cons, Handle<Object>(context->initial_object_prototype(), isolate)); 889 cons, Handle<Object>(context->initial_object_prototype(), isolate));
890 cons->shared()->set_instance_class_name(*name); 890 cons->shared()->set_instance_class_name(*name);
891 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED); 891 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED);
892 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM); 892 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM);
893 JSObject::AddProperty(global, name, wasm_object, attributes); 893 JSObject::AddProperty(global, name, wasm_object, attributes);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 if (!memory_object->IsUndefined(isolate)) { 974 if (!memory_object->IsUndefined(isolate)) {
975 DCHECK(IsWasmMemoryObject(isolate, memory_object)); 975 DCHECK(IsWasmMemoryObject(isolate, memory_object));
976 // TODO(gdeepti): This should be a weak list of instance objects 976 // TODO(gdeepti): This should be a weak list of instance objects
977 // for instances that share memory. 977 // for instances that share memory.
978 JSObject::cast(*memory_object) 978 JSObject::cast(*memory_object)
979 ->SetInternalField(kWasmMemoryInstanceObject, *instance); 979 ->SetInternalField(kWasmMemoryInstanceObject, *instance);
980 } 980 }
981 } 981 }
982 } // namespace internal 982 } // namespace internal
983 } // namespace v8 983 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-debug.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698