Changeset 214484 in webkit
- Timestamp:
- Mar 28, 2017 11:41:53 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r214438 r214484 1 2017-03-28 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: implement Module imports/exports 4 https://bugs.webkit.org/show_bug.cgi?id=166982 5 6 Reviewed by Saam Barati. 7 8 * wasm/js-api/Module.exports.js: Added. 9 (assert.throws.WebAssembly.Module.prototype.exports): 10 (assert.eq): 11 * wasm/js-api/Module.imports.js: Added. 12 (assert.throws.WebAssembly.Module.prototype.imports): 13 (assert.eq): 14 1 15 2017-03-27 JF Bastien <jfbastien@apple.com> 2 16 -
trunk/Source/JavaScriptCore/ChangeLog
r214465 r214484 1 2017-03-28 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: implement Module imports/exports 4 https://bugs.webkit.org/show_bug.cgi?id=166982 5 6 Reviewed by Saam Barati. 7 8 As defined in: https://github.com/WebAssembly/design/commit/18cbacb90cd3584dd5c9aa3d392e4e55f66af6ab 9 10 * wasm/WasmFormat.h: 11 (JSC::Wasm::makeString): use uppercase instead, it was only used 12 for diagnostic but is now used for the expected JS property's 13 capitalization 14 * wasm/js/WebAssemblyModulePrototype.cpp: 15 (JSC::webAssemblyModuleProtoImports): 16 (JSC::webAssemblyModuleProtoExports): 17 1 18 2017-03-27 JF Bastien <jfbastien@apple.com> 2 19 -
trunk/Source/JavaScriptCore/wasm/WasmFormat.h
r213465 r214484 1 1 /* 2 * Copyright (C) 2015-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 93 93 { 94 94 switch (kind) { 95 case ExternalKind::Function: return " Function";96 case ExternalKind::Table: return " Table";97 case ExternalKind::Memory: return " Memory";98 case ExternalKind::Global: return " Global";95 case ExternalKind::Function: return "function"; 96 case ExternalKind::Table: return "table"; 97 case ExternalKind::Memory: return "memory"; 98 case ExternalKind::Global: return "global"; 99 99 } 100 100 RELEASE_ASSERT_NOT_REACHED(); -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.cpp
r211247 r214484 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 #include "JSCInlines.h" 35 35 #include "JSWebAssemblyModule.h" 36 #include "ObjectConstructor.h" 36 37 37 38 namespace JSC { 38 39 static EncodedJSValue JSC_HOST_CALL webAssemblyModuleProtoCustomSections(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL webAssemblyModuleProtoImports(ExecState*); 41 static EncodedJSValue JSC_HOST_CALL webAssemblyModuleProtoExports(ExecState*); 39 42 } 40 43 … … 48 51 @begin prototypeTableWebAssemblyModule 49 52 customSections webAssemblyModuleProtoCustomSections DontEnum|Function 1 53 imports webAssemblyModuleProtoImports DontEnum|Accessor 0 54 exports webAssemblyModuleProtoExports DontEnum|Accessor 0 50 55 @end 51 56 */ … … 59 64 JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->thisValue()); 60 65 if (!module) 61 throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Module.prototype.customSections called with non WebAssembly.Module |this| value"))); 62 RETURN_IF_EXCEPTION(throwScope, { }); 66 return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Module.prototype.customSections called with non WebAssembly.Module |this| value")))); 63 67 64 68 const String sectionNameString = exec->argument(0).getString(exec); … … 73 77 auto buffer = ArrayBuffer::tryCreate(section.payload.data(), section.payload.size()); 74 78 if (!buffer) 75 throwException(exec, throwScope, createOutOfMemoryError(exec));79 return JSValue::encode(throwException(exec, throwScope, createOutOfMemoryError(exec))); 76 80 77 81 Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, JSValue(), globalObject->arrayBufferStructure(ArrayBufferSharingMode::Default)); … … 79 83 80 84 result->push(exec, JSArrayBuffer::create(vm, arrayBufferStructure, WTFMove(buffer))); 85 RETURN_IF_EXCEPTION(throwScope, { }); 86 } 87 } 88 89 return JSValue::encode(result); 90 } 91 92 EncodedJSValue JSC_HOST_CALL webAssemblyModuleProtoImports(ExecState* exec) 93 { 94 VM& vm = exec->vm(); 95 auto* globalObject = exec->lexicalGlobalObject(); 96 auto throwScope = DECLARE_THROW_SCOPE(vm); 97 98 JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->thisValue()); 99 if (!module) 100 return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Module.prototype.imports called with non WebAssembly.Module |this| value")))); 101 102 JSArray* result = constructEmptyArray(exec, nullptr, globalObject); 103 RETURN_IF_EXCEPTION(throwScope, { }); 104 105 const auto& imports = module->moduleInformation().imports; 106 if (imports.size()) { 107 Identifier module = Identifier::fromString(exec, "module"); 108 Identifier name = Identifier::fromString(exec, "name"); 109 Identifier kind = Identifier::fromString(exec, "kind"); 110 for (const Wasm::Import& imp : imports) { 111 JSObject* obj = constructEmptyObject(exec); 112 RETURN_IF_EXCEPTION(throwScope, { }); 113 obj->putDirect(vm, module, jsString(exec, imp.module.string())); 114 obj->putDirect(vm, name, jsString(exec, imp.field.string())); 115 obj->putDirect(vm, kind, jsString(exec, String(makeString(imp.kind)))); 116 result->push(exec, obj); 117 RETURN_IF_EXCEPTION(throwScope, { }); 118 } 119 } 120 121 return JSValue::encode(result); 122 } 123 124 EncodedJSValue JSC_HOST_CALL webAssemblyModuleProtoExports(ExecState* exec) 125 { 126 VM& vm = exec->vm(); 127 auto* globalObject = exec->lexicalGlobalObject(); 128 auto throwScope = DECLARE_THROW_SCOPE(vm); 129 130 JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->thisValue()); 131 if (!module) 132 return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Module.prototype.exports called with non WebAssembly.Module |this| value")))); 133 134 JSArray* result = constructEmptyArray(exec, nullptr, globalObject); 135 RETURN_IF_EXCEPTION(throwScope, { }); 136 137 const auto& exports = module->moduleInformation().exports; 138 if (exports.size()) { 139 Identifier name = Identifier::fromString(exec, "name"); 140 Identifier kind = Identifier::fromString(exec, "kind"); 141 for (const Wasm::Export& exp : exports) { 142 JSObject* obj = constructEmptyObject(exec); 143 RETURN_IF_EXCEPTION(throwScope, { }); 144 obj->putDirect(vm, name, jsString(exec, exp.field.string())); 145 obj->putDirect(vm, kind, jsString(exec, String(makeString(exp.kind)))); 146 result->push(exec, obj); 81 147 RETURN_IF_EXCEPTION(throwScope, { }); 82 148 }
Note: See TracChangeset
for help on using the changeset viewer.