Closed
Bug 1095740
Opened 11 years ago
Closed 11 years ago
OdinMonkey: refine rules for 'const'
Categories
(Core :: JavaScript Engine: JIT, defect)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
FIXED
mozilla36
People
(Reporter: luke, Assigned: luke)
Details
Attachments
(1 file)
|
18.74 KB,
patch
|
bbouvier
:
review+
|
Details | Diff | Splinter Review |
This patch tweaks the rules for const in asm.js:
- It gives 'const' globals the exact type of the literal which is more precise than the 'int' type given to variables.
- It allows const literals to be used without coercion in return statements (for symmetry with their use in var initializers).
Attachment #8519198 -
Flags: review?(benj)
Comment 1•11 years ago
|
||
Comment on attachment 8519198 [details] [diff] [review]
const-tweaks
Review of attachment 8519198 [details] [diff] [review]:
-----------------------------------------------------------------
Nice simplification!
Double check me here, but iiuc, there is no risk that this breaks demos (as before this patch, the validation rules were stricter; and some |0 or >>>0 were needed at places where this is not needed after this patch).
::: js/src/asmjs/AsmJSValidate.cpp
@@ +1567,5 @@
> void initBufferArgumentName(PropertyName *n) { module_->initBufferArgumentName(n); }
>
> bool addGlobalVarInit(PropertyName *varName, const AsmJSNumLit &lit, bool isConst) {
> uint32_t index;
> + Type type = isConst ? Type::Of(lit) : VarType::Of(lit).toType();
Might be worth a comment that this distinction gives const integer variables their precise Type rather than just "int", what do you think?
::: js/src/jit-test/tests/asm.js/testControlFlow.js
@@ +18,5 @@
> +assertAsmTypeFail(USE_ASM + "const M = 42; function f() { return M } function g() { return +f() } return f");
> +assertEq(asmLink(asmCompile(USE_ASM + "const M = 42.1; function f() { return M } function g() { return +f() } return f"))(), 42.1);
> +assertAsmTypeFail(USE_ASM + "const M = 42.1; function f() { return M } function g() { return f()|0 } return f");
> +assertEq(asmLink(asmCompile('glob', USE_ASM + "var tof = glob.Math.fround; const M = tof(42); function f() { return M } function g() { return tof(f()) } return f"), this)(), 42);
> +assertAsmTypeFail('glob', USE_ASM + "var tof = glob.Math.fround; const M = tof(42); function f() { return M } function g() { return +f() } return f");
(really not important, but shouldn't these be in testCall instead?)
Attachment #8519198 -
Flags: review?(benj) → review+
| Assignee | ||
Comment 2•11 years ago
|
||
(In reply to Benjamin Bouvier [:bbouvier] from comment #1)
> Double check me here, but iiuc, there is no risk that this breaks demos
That's right; the literal type is a subtype of the vartype. Agreed with your other suggestions.
https://hg.mozilla.org/integration/mozilla-inbound/rev/c617a998c239
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in
before you can comment on or make changes to this bug.
Description
•