Skip to content

Commit 9286f56

Browse files
fix: Move argument sanitization to when writing strings only
1 parent 978a0bf commit 9286f56

File tree

10 files changed

+230
-56
lines changed

10 files changed

+230
-56
lines changed

dist/gpu-browser-core.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 2.6.8
8-
* @date Sun Feb 16 2020 14:37:32 GMT-0500 (Eastern Standard Time)
7+
* @version 2.6.9
8+
* @date Sun Feb 16 2020 15:57:16 GMT-0500 (Eastern Standard Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -5908,7 +5908,6 @@ class KernelValue {
59085908
this.name = name;
59095909
this.origin = origin;
59105910
this.tactic = tactic;
5911-
this.id = `${this.origin}_${name}`;
59125911
this.varName = origin === 'constants' ? `constants.${name}` : name;
59135912
this.kernel = kernel;
59145913
this.strictIntegers = strictIntegers;
@@ -5923,6 +5922,10 @@ class KernelValue {
59235922
this.forceUploadEachRun = null;
59245923
}
59255924

5925+
get id() {
5926+
return `${this.origin}_${name}`;
5927+
}
5928+
59265929
getSource() {
59275930
throw new Error(`"getSource" not defined on ${ this.constructor.name }`);
59285931
}
@@ -7962,7 +7965,7 @@ class WebGLFunctionNode extends FunctionNode {
79627965
case 'Array(2)':
79637966
case 'Array(3)':
79647967
case 'Array(4)':
7965-
retArr.push(`constants_${ name }`);
7968+
retArr.push(`constants_${ utils.sanitizeName(name) }`);
79667969
return retArr;
79677970
}
79687971
}
@@ -7998,12 +8001,12 @@ class WebGLFunctionNode extends FunctionNode {
79988001
case 'Integer':
79998002
case 'Float':
80008003
case 'Boolean':
8001-
retArr.push(`${origin}_${name}`);
8004+
retArr.push(`${origin}_${utils.sanitizeName(name)}`);
80028005
return retArr;
80038006
}
80048007
}
80058008

8006-
const markupName = `${origin}_${name}`;
8009+
const markupName = `${origin}_${utils.sanitizeName(name)}`;
80078010

80088011
switch (type) {
80098012
case 'Array(2)':
@@ -9013,6 +9016,7 @@ module.exports = {
90139016
WebGLKernelValueHTMLVideo
90149017
};
90159018
},{"./html-image":53}],55:[function(require,module,exports){
9019+
const { utils } = require('../../../utils');
90169020
const { KernelValue } = require('../../kernel-value');
90179021

90189022
class WebGLKernelValue extends KernelValue {
@@ -9029,6 +9033,10 @@ class WebGLKernelValue extends KernelValue {
90299033
this.prevArg = null;
90309034
}
90319035

9036+
get id() {
9037+
return `${this.origin}_${utils.sanitizeName(this.name)}`;
9038+
}
9039+
90329040
setup() {}
90339041

90349042
getTransferArrayType(value) {
@@ -9067,7 +9075,7 @@ class WebGLKernelValue extends KernelValue {
90679075
module.exports = {
90689076
WebGLKernelValue
90699077
};
9070-
},{"../../kernel-value":34}],56:[function(require,module,exports){
9078+
},{"../../../utils":113,"../../kernel-value":34}],56:[function(require,module,exports){
90719079
const { utils } = require('../../../utils');
90729080
const { WebGLKernelValue } = require('./index');
90739081

@@ -9977,7 +9985,7 @@ class WebGLKernel extends GLKernel {
99779985

99789986
for (let index = 0; index < args.length; index++) {
99799987
const value = args[index];
9980-
const name = utils.sanitizeName(this.argumentNames[index]);
9988+
const name = this.argumentNames[index];
99819989
let type;
99829990
if (needsArgumentTypes) {
99839991
type = utils.getVariableType(value, this.strictIntegers);

dist/gpu-browser-core.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gpu-browser.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 2.6.8
8-
* @date Sun Feb 16 2020 14:37:32 GMT-0500 (Eastern Standard Time)
7+
* @version 2.6.9
8+
* @date Sun Feb 16 2020 15:57:16 GMT-0500 (Eastern Standard Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -10342,7 +10342,6 @@ class KernelValue {
1034210342
this.name = name;
1034310343
this.origin = origin;
1034410344
this.tactic = tactic;
10345-
this.id = `${this.origin}_${name}`;
1034610345
this.varName = origin === 'constants' ? `constants.${name}` : name;
1034710346
this.kernel = kernel;
1034810347
this.strictIntegers = strictIntegers;
@@ -10357,6 +10356,10 @@ class KernelValue {
1035710356
this.forceUploadEachRun = null;
1035810357
}
1035910358

10359+
get id() {
10360+
return `${this.origin}_${name}`;
10361+
}
10362+
1036010363
getSource() {
1036110364
throw new Error(`"getSource" not defined on ${ this.constructor.name }`);
1036210365
}
@@ -12396,7 +12399,7 @@ class WebGLFunctionNode extends FunctionNode {
1239612399
case 'Array(2)':
1239712400
case 'Array(3)':
1239812401
case 'Array(4)':
12399-
retArr.push(`constants_${ name }`);
12402+
retArr.push(`constants_${ utils.sanitizeName(name) }`);
1240012403
return retArr;
1240112404
}
1240212405
}
@@ -12432,12 +12435,12 @@ class WebGLFunctionNode extends FunctionNode {
1243212435
case 'Integer':
1243312436
case 'Float':
1243412437
case 'Boolean':
12435-
retArr.push(`${origin}_${name}`);
12438+
retArr.push(`${origin}_${utils.sanitizeName(name)}`);
1243612439
return retArr;
1243712440
}
1243812441
}
1243912442

12440-
const markupName = `${origin}_${name}`;
12443+
const markupName = `${origin}_${utils.sanitizeName(name)}`;
1244112444

1244212445
switch (type) {
1244312446
case 'Array(2)':
@@ -13447,6 +13450,7 @@ module.exports = {
1344713450
WebGLKernelValueHTMLVideo
1344813451
};
1344913452
},{"./html-image":54}],56:[function(require,module,exports){
13453+
const { utils } = require('../../../utils');
1345013454
const { KernelValue } = require('../../kernel-value');
1345113455

1345213456
class WebGLKernelValue extends KernelValue {
@@ -13463,6 +13467,10 @@ class WebGLKernelValue extends KernelValue {
1346313467
this.prevArg = null;
1346413468
}
1346513469

13470+
get id() {
13471+
return `${this.origin}_${utils.sanitizeName(this.name)}`;
13472+
}
13473+
1346613474
setup() {}
1346713475

1346813476
getTransferArrayType(value) {
@@ -13501,7 +13509,7 @@ class WebGLKernelValue extends KernelValue {
1350113509
module.exports = {
1350213510
WebGLKernelValue
1350313511
};
13504-
},{"../../kernel-value":35}],57:[function(require,module,exports){
13512+
},{"../../../utils":114,"../../kernel-value":35}],57:[function(require,module,exports){
1350513513
const { utils } = require('../../../utils');
1350613514
const { WebGLKernelValue } = require('./index');
1350713515

@@ -14411,7 +14419,7 @@ class WebGLKernel extends GLKernel {
1441114419

1441214420
for (let index = 0; index < args.length; index++) {
1441314421
const value = args[index];
14414-
const name = utils.sanitizeName(this.argumentNames[index]);
14422+
const name = this.argumentNames[index];
1441514423
let type;
1441614424
if (needsArgumentTypes) {
1441714425
type = utils.getVariableType(value, this.strictIntegers);

dist/gpu-browser.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gpu.js",
3-
"version": "2.6.8",
3+
"version": "2.6.9",
44
"description": "GPU Accelerated JavaScript",
55
"engines": {
66
"node": ">=8.0.0"

src/backend/kernel-value.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class KernelValue {
3737
this.name = name;
3838
this.origin = origin;
3939
this.tactic = tactic;
40-
this.id = `${this.origin}_${name}`;
4140
this.varName = origin === 'constants' ? `constants.${name}` : name;
4241
this.kernel = kernel;
4342
this.strictIntegers = strictIntegers;
@@ -53,6 +52,10 @@ class KernelValue {
5352
this.forceUploadEachRun = null;
5453
}
5554

55+
get id() {
56+
return `${this.origin}_${name}`;
57+
}
58+
5659
getSource() {
5760
throw new Error(`"getSource" not defined on ${ this.constructor.name }`);
5861
}

src/backend/web-gl/function-node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ class WebGLFunctionNode extends FunctionNode {
11421142
case 'Array(2)':
11431143
case 'Array(3)':
11441144
case 'Array(4)':
1145-
retArr.push(`constants_${ name }`);
1145+
retArr.push(`constants_${ utils.sanitizeName(name) }`);
11461146
return retArr;
11471147
}
11481148
}
@@ -1179,14 +1179,14 @@ class WebGLFunctionNode extends FunctionNode {
11791179
case 'Integer':
11801180
case 'Float':
11811181
case 'Boolean':
1182-
retArr.push(`${origin}_${name}`);
1182+
retArr.push(`${origin}_${utils.sanitizeName(name)}`);
11831183
return retArr;
11841184
}
11851185
}
11861186

11871187
// handle more complex types
11881188
// argument may have come from a parent
1189-
const markupName = `${origin}_${name}`;
1189+
const markupName = `${origin}_${utils.sanitizeName(name)}`;
11901190

11911191
switch (type) {
11921192
case 'Array(2)':

src/backend/web-gl/kernel-value/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { utils } = require('../../../utils');
12
const { KernelValue } = require('../../kernel-value');
23

34
class WebGLKernelValue extends KernelValue {
@@ -18,6 +19,10 @@ class WebGLKernelValue extends KernelValue {
1819
this.prevArg = null;
1920
}
2021

22+
get id() {
23+
return `${this.origin}_${utils.sanitizeName(this.name)}`;
24+
}
25+
2126
setup() {}
2227

2328
getTransferArrayType(value) {

src/backend/web-gl/kernel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ class WebGLKernel extends GLKernel {
377377

378378
for (let index = 0; index < args.length; index++) {
379379
const value = args[index];
380-
const name = utils.sanitizeName(this.argumentNames[index]);
380+
const name = this.argumentNames[index];
381381
let type;
382382
if (needsArgumentTypes) {
383383
type = utils.getVariableType(value, this.strictIntegers);

0 commit comments

Comments
 (0)