|
Lines 1-5
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec1
|
| 1 |
/* |
1 |
/* |
| 2 |
* Copyright (C) 2016 Apple Inc. All rights reserved. |
2 |
* Copyright (C) 2016-2017 Apple Inc. All rights reserved. |
| 3 |
* |
3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions |
5 |
* modification, are permitted provided that the following conditions |
|
Lines 33-38
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec2
|
| 33 |
#include "JSWebAssemblyHelpers.h" |
33 |
#include "JSWebAssemblyHelpers.h" |
| 34 |
#include "JSWebAssemblyTable.h" |
34 |
#include "JSWebAssemblyTable.h" |
| 35 |
|
35 |
|
|
|
36 |
namespace JSC { |
| 37 |
static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncLength(ExecState*); |
| 38 |
static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGrow(ExecState*); |
| 39 |
static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGet(ExecState*); |
| 40 |
static EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState*); |
| 41 |
} |
| 42 |
|
| 36 |
#include "WebAssemblyTablePrototype.lut.h" |
43 |
#include "WebAssemblyTablePrototype.lut.h" |
| 37 |
|
44 |
|
| 38 |
namespace JSC { |
45 |
namespace JSC { |
|
Lines 41-46
const ClassInfo WebAssemblyTablePrototype::s_info = { "WebAssembly.Table.prototy
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec3
|
| 41 |
|
48 |
|
| 42 |
/* Source for WebAssemblyTablePrototype.lut.h |
49 |
/* Source for WebAssemblyTablePrototype.lut.h |
| 43 |
@begin prototypeTableWebAssemblyTable |
50 |
@begin prototypeTableWebAssemblyTable |
|
|
51 |
length webAssemblyTableProtoFuncLength DontEnum|Accessor 0 |
| 52 |
grow webAssemblyTableProtoFuncGrow DontEnum|Function 1 |
| 53 |
get webAssemblyTableProtoFuncGet DontEnum|Function 1 |
| 54 |
set webAssemblyTableProtoFuncSet DontEnum|Function 2 |
| 44 |
@end |
55 |
@end |
| 45 |
*/ |
56 |
*/ |
| 46 |
|
57 |
|
|
Lines 56-66
static ALWAYS_INLINE JSWebAssemblyTable* getTable(ExecState* exec, VM& vm, JSVal
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec4
|
| 56 |
return result; |
67 |
return result; |
| 57 |
} |
68 |
} |
| 58 |
|
69 |
|
| 59 |
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncLength(ExecState*); |
|
|
| 60 |
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGrow(ExecState*); |
| 61 |
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGet(ExecState*); |
| 62 |
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState*); |
| 63 |
|
| 64 |
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncLength(ExecState* exec) |
70 |
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncLength(ExecState* exec) |
| 65 |
{ |
71 |
{ |
| 66 |
VM& vm = exec->vm(); |
72 |
VM& vm = exec->vm(); |
|
Lines 81-91
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGrow(ExecState* exec)
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec5
|
| 81 |
|
87 |
|
| 82 |
uint32_t index = toNonWrappingUint32(exec, exec->argument(0)); |
88 |
uint32_t index = toNonWrappingUint32(exec, exec->argument(0)); |
| 83 |
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
89 |
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 84 |
if (!table->grow(index)) { |
90 |
if (!table->grow(index)) |
| 85 |
throwException(exec, throwScope, |
91 |
return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Table.prototype.grow could not grow the table")))); |
| 86 |
createTypeError(exec, ASCIILiteral("WebAssembly.Table.prototype.grow could not grow the table"))); |
|
|
| 87 |
return { }; |
| 88 |
} |
| 89 |
|
92 |
|
| 90 |
return JSValue::encode(jsUndefined()); |
93 |
return JSValue::encode(jsUndefined()); |
| 91 |
} |
94 |
} |
|
Lines 100-110
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncGet(ExecState* exec)
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec6
|
| 100 |
|
103 |
|
| 101 |
uint32_t index = toNonWrappingUint32(exec, exec->argument(0)); |
104 |
uint32_t index = toNonWrappingUint32(exec, exec->argument(0)); |
| 102 |
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
105 |
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 103 |
if (index >= table->size()) { |
106 |
if (index >= table->size()) |
| 104 |
throwException(exec, throwScope, |
107 |
return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, ASCIILiteral("WebAssembly.Table.prototype.get expects an integer less than the size of the table")))); |
| 105 |
createRangeError(exec, ASCIILiteral("WebAssembly.Table.prototype.get expects an integer less than the size of the table"))); |
|
|
| 106 |
return { }; |
| 107 |
} |
| 108 |
|
108 |
|
| 109 |
if (JSObject* result = table->getFunction(index)) |
109 |
if (JSObject* result = table->getFunction(index)) |
| 110 |
return JSValue::encode(result); |
110 |
return JSValue::encode(result); |
|
Lines 122-141
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState* exec)
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec7
|
| 122 |
JSValue value = exec->argument(1); |
122 |
JSValue value = exec->argument(1); |
| 123 |
WebAssemblyFunction* wasmFunction; |
123 |
WebAssemblyFunction* wasmFunction; |
| 124 |
WebAssemblyWrapperFunction* wasmWrapperFunction; |
124 |
WebAssemblyWrapperFunction* wasmWrapperFunction; |
| 125 |
if (!value.isNull() && !isWebAssemblyHostFunction(vm, value, wasmFunction, wasmWrapperFunction)) { |
125 |
if (!value.isNull() && !isWebAssemblyHostFunction(vm, value, wasmFunction, wasmWrapperFunction)) |
| 126 |
throwException(exec, throwScope, |
126 |
return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Table.prototype.set expects the second argument to be null or an instance of WebAssembly.Function")))); |
| 127 |
createTypeError(exec, ASCIILiteral("WebAssembly.Table.prototype.set expects the second argument to be null or an instance of WebAssembly.Function"))); |
|
|
| 128 |
return { }; |
| 129 |
} |
| 130 |
|
127 |
|
| 131 |
uint32_t index = toNonWrappingUint32(exec, exec->argument(0)); |
128 |
uint32_t index = toNonWrappingUint32(exec, exec->argument(0)); |
| 132 |
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
129 |
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 133 |
|
130 |
|
| 134 |
if (index >= table->size()) { |
131 |
if (index >= table->size()) |
| 135 |
throwException(exec, throwScope, |
132 |
return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, ASCIILiteral("WebAssembly.Table.prototype.set expects an integer less than the size of the table")))); |
| 136 |
createRangeError(exec, ASCIILiteral("WebAssembly.Table.prototype.set expects an integer less than the size of the table"))); |
|
|
| 137 |
return { }; |
| 138 |
} |
| 139 |
|
133 |
|
| 140 |
if (value.isNull()) |
134 |
if (value.isNull()) |
| 141 |
table->clearFunction(index); |
135 |
table->clearFunction(index); |
|
Lines 151-160
EncodedJSValue JSC_HOST_CALL webAssemblyTableProtoFuncSet(ExecState* exec)
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec8
|
| 151 |
return JSValue::encode(jsUndefined()); |
145 |
return JSValue::encode(jsUndefined()); |
| 152 |
} |
146 |
} |
| 153 |
|
147 |
|
| 154 |
WebAssemblyTablePrototype* WebAssemblyTablePrototype::create(VM& vm, JSGlobalObject* globalObject, Structure* structure) |
148 |
WebAssemblyTablePrototype* WebAssemblyTablePrototype::create(VM& vm, JSGlobalObject*, Structure* structure) |
| 155 |
{ |
149 |
{ |
| 156 |
auto* object = new (NotNull, allocateCell<WebAssemblyTablePrototype>(vm.heap)) WebAssemblyTablePrototype(vm, structure); |
150 |
auto* object = new (NotNull, allocateCell<WebAssemblyTablePrototype>(vm.heap)) WebAssemblyTablePrototype(vm, structure); |
| 157 |
object->finishCreation(vm, globalObject); |
151 |
object->finishCreation(vm); |
| 158 |
return object; |
152 |
return object; |
| 159 |
} |
153 |
} |
| 160 |
|
154 |
|
|
Lines 163-176
Structure* WebAssemblyTablePrototype::createStructure(VM& vm, JSGlobalObject* gl
a/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp_sec9
|
| 163 |
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); |
157 |
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); |
| 164 |
} |
158 |
} |
| 165 |
|
159 |
|
| 166 |
void WebAssemblyTablePrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) |
160 |
void WebAssemblyTablePrototype::finishCreation(VM& vm) |
| 167 |
{ |
161 |
{ |
| 168 |
Base::finishCreation(vm); |
162 |
Base::finishCreation(vm); |
| 169 |
|
163 |
ASSERT(inherits(vm, info())); |
| 170 |
JSC_NATIVE_GETTER("length", webAssemblyTableProtoFuncLength, DontEnum | Accessor); |
|
|
| 171 |
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("grow", webAssemblyTableProtoFuncGrow, DontEnum, 1); |
| 172 |
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("get", webAssemblyTableProtoFuncGet, DontEnum, 1); |
| 173 |
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("set", webAssemblyTableProtoFuncSet, DontEnum, 2); |
| 174 |
} |
164 |
} |
| 175 |
|
165 |
|
| 176 |
WebAssemblyTablePrototype::WebAssemblyTablePrototype(VM& vm, Structure* structure) |
166 |
WebAssemblyTablePrototype::WebAssemblyTablePrototype(VM& vm, Structure* structure) |