Changeset 217097 in webkit
- Timestamp:
- May 18, 2017 10:27:28 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r217093 r217097 1 2017-05-18 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: exports is a getter 4 https://bugs.webkit.org/show_bug.cgi?id=172129 5 6 Reviewed by Saam Barati. 7 8 Update test to reflect new semantics. 9 10 * wasm/js-api/test_basic_api.js: 11 (const.c.in.constructorProperties.switch): 12 1 13 2017-05-18 Saam Barati <sbarati@apple.com> 2 14 -
trunk/JSTests/wasm/js-api/test_basic_api.js
r217052 r217097 11 11 assert.eq(typeof descriptor.value, expect.typeofvalue); 12 12 assert.eq(descriptor.writable, expect.writable); 13 assert.eq(descriptor.configurable, expect.configurable); 14 assert.eq(descriptor.enumerable, expect.enumerable); 15 }; 16 17 const checkAccessorOwnPropertyDescriptor = (obj, prop, expect) => { 18 const descriptor = Object.getOwnPropertyDescriptor(obj, prop); 19 assert.eq(typeof descriptor.value, "undefined"); 20 assert.eq(typeof descriptor.writable, "undefined"); 13 21 assert.eq(descriptor.configurable, expect.configurable); 14 22 assert.eq(descriptor.enumerable, expect.enumerable); … … 71 79 assert.throws(() => new WebAssembly[c](new WebAssembly.Module(emptyModuleArray), invalid), TypeError, `second argument to WebAssembly.Instance must be undefined or an Object (evaluating 'new WebAssembly[c](new WebAssembly.Module(emptyModuleArray), invalid)')`); 72 80 assert.isNotUndef(instance.exports); 73 checkOwnPropertyDescriptor(instance, "exports", { typeofvalue: "object", writable: true, configurable: true, enumerable: true }); 81 checkAccessorOwnPropertyDescriptor(WebAssembly.Instance.prototype, "exports", { configurable: true, enumerable: false }); 82 assert.throws(() => WebAssembly.Instance.prototype.exports = undefined, TypeError, `Attempted to assign to readonly property.`); 83 assert.throws(() => WebAssembly.Instance.prototype.exports, TypeError, `expected |this| value to be an instance of WebAssembly.Instance`); 74 84 assert.isUndef(instance.exports.__proto__); 75 85 assert.eq(Reflect.isExtensible(instance.exports), false); -
trunk/Source/JavaScriptCore/ChangeLog
r217093 r217097 1 2017-05-18 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: exports is a getter 4 https://bugs.webkit.org/show_bug.cgi?id=172129 5 6 Reviewed by Saam Barati. 7 8 As updated here: https://github.com/WebAssembly/design/pull/1062 9 10 * wasm/js/JSWebAssemblyInstance.cpp: 11 (JSC::JSWebAssemblyInstance::finishCreation): don't putDirect here anymore 12 * wasm/js/JSWebAssemblyInstance.h: 13 (JSC::JSWebAssemblyInstance::moduleNamespaceObject): add accessor 14 * wasm/js/WebAssemblyFunctionBase.cpp: squelch causing a warning 15 * wasm/js/WebAssemblyInstancePrototype.cpp: use LUT 16 (JSC::getInstance): helper, as in surrounding files 17 (JSC::webAssemblyInstanceProtoFuncExports): instead of putDirect 18 * wasm/js/WebAssemblyMemoryPrototype.cpp: pass VM around as for Table 19 (JSC::getMemory): 20 (JSC::webAssemblyMemoryProtoFuncGrow): 21 (JSC::webAssemblyMemoryProtoFuncBuffer): 22 * wasm/js/WebAssemblyTablePrototype.cpp: static everywhere as with other code 23 (JSC::webAssemblyTableProtoFuncLength): 24 (JSC::webAssemblyTableProtoFuncGrow): 25 (JSC::webAssemblyTableProtoFuncGet): 26 (JSC::webAssemblyTableProtoFuncSet): 27 1 28 2017-05-18 Saam Barati <sbarati@apple.com> 2 29 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
r217049 r217097 70 70 m_moduleNamespaceObject.set(vm, this, moduleNamespaceObject); 71 71 m_callee.set(vm, this, module->callee()); 72 putDirect(vm, Identifier::fromString(&vm, "exports"), moduleNamespaceObject, None);73 72 } 74 73 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
r217060 r217097 55 55 56 56 JSObject* importFunction(unsigned idx) { RELEASE_ASSERT(idx < m_numImportFunctions); return importFunctions()[idx].get(); } 57 58 JSModuleNamespaceObject* moduleNamespaceObject() { return m_moduleNamespaceObject.get(); } 57 59 58 60 JSWebAssemblyMemory* memory() { return m_memory.get(); } -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp
r217049 r217097 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 … … 31 31 #include "FunctionPrototype.h" 32 32 #include "JSCInlines.h" 33 #include "JSModuleNamespaceObject.h" 34 #include "JSWebAssemblyInstance.h" 35 36 namespace JSC { 37 static EncodedJSValue JSC_HOST_CALL webAssemblyInstanceProtoFuncExports(ExecState*); 38 } 33 39 34 40 #include "WebAssemblyInstancePrototype.lut.h" … … 40 46 /* Source for WebAssemblyInstancePrototype.lut.h 41 47 @begin prototypeTableWebAssemblyInstance 48 exports webAssemblyInstanceProtoFuncExports DontEnum|Accessor 0 42 49 @end 43 50 */ 51 52 static ALWAYS_INLINE JSWebAssemblyInstance* getInstance(ExecState* exec, VM& vm, JSValue v) 53 { 54 auto throwScope = DECLARE_THROW_SCOPE(vm); 55 JSWebAssemblyInstance* result = jsDynamicCast<JSWebAssemblyInstance*>(vm, v); 56 if (!result) { 57 throwException(exec, throwScope, 58 createTypeError(exec, ASCIILiteral("expected |this| value to be an instance of WebAssembly.Instance"))); 59 return nullptr; 60 } 61 return result; 62 } 63 64 static EncodedJSValue JSC_HOST_CALL webAssemblyInstanceProtoFuncExports(ExecState* exec) 65 { 66 VM& vm = exec->vm(); 67 auto throwScope = DECLARE_THROW_SCOPE(vm); 68 69 JSWebAssemblyInstance* instance = getInstance(exec, vm, exec->thisValue()); 70 RETURN_IF_EXCEPTION(throwScope, { }); 71 return JSValue::encode(instance->moduleNamespaceObject()); 72 } 44 73 45 74 WebAssemblyInstancePrototype* WebAssemblyInstancePrototype::create(VM& vm, JSGlobalObject*, Structure* structure) -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp
r217049 r217097 54 54 */ 55 55 56 ALWAYS_INLINE JSWebAssemblyMemory* getMemory(ExecState* exec, JSValue value)56 ALWAYS_INLINE JSWebAssemblyMemory* getMemory(ExecState* exec, VM& vm, JSValue value) 57 57 { 58 VM& vm = exec->vm();59 58 auto throwScope = DECLARE_THROW_SCOPE(vm); 60 59 … … 73 72 auto throwScope = DECLARE_THROW_SCOPE(vm); 74 73 75 JSWebAssemblyMemory* memory = getMemory(exec, exec->thisValue());74 JSWebAssemblyMemory* memory = getMemory(exec, vm, exec->thisValue()); 76 75 RETURN_IF_EXCEPTION(throwScope, { }); 77 76 … … 91 90 auto throwScope = DECLARE_THROW_SCOPE(vm); 92 91 93 JSWebAssemblyMemory* memory = getMemory(exec, exec->thisValue());92 JSWebAssemblyMemory* memory = getMemory(exec, vm, exec->thisValue()); 94 93 RETURN_IF_EXCEPTION(throwScope, { }); 95 94 return JSValue::encode(memory->buffer(exec->vm(), exec->lexicalGlobalObject())); -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp
r217049 r217097 68 68 } 69 69 70 EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncLength(ExecState* exec)70 static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncLength(ExecState* exec) 71 71 { 72 72 VM& vm = exec->vm(); … … 78 78 } 79 79 80 EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGrow(ExecState* exec)80 static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGrow(ExecState* exec) 81 81 { 82 82 VM& vm = exec->vm(); … … 94 94 } 95 95 96 EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGet(ExecState* exec)96 static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGet(ExecState* exec) 97 97 { 98 98 VM& vm = exec->vm(); … … 112 112 } 113 113 114 EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState* exec)114 static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState* exec) 115 115 { 116 116 VM& vm = exec->vm();
Note: See TracChangeset
for help on using the changeset viewer.