mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877338: Add alias analysis and GVN for global variable loads / stores in asm.js; r=jandem
This commit is contained in:
parent
c85757df27
commit
a8fb839ea0
@ -104,3 +104,8 @@ var p = new Proxy(global,
|
||||
getOwnPropertyDescriptor:function(name) { return {value:Int32Array}}});
|
||||
new Int32Array(ab)[4] = 42;
|
||||
assertEq(f1(p, null, ab)(), 42);
|
||||
|
||||
// GVN checks
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "var g=0; function f() { var x = 0; g = 1; x = g; return (x+g)|0 } return f"))(), 2);
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "var g=0; function f() { var x = 0; g = 1; x = g; g = 2; return (x+g)|0 } return f"))(), 3);
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "var g=0; var h=0; function f() { var x = 0; g = 1; x = g; h = 3; return (x+g)|0 } return f"))(), 2);
|
||||
|
@ -2432,6 +2432,26 @@ MLoadFixedSlot::mightAlias(MDefinition *store)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MAsmJSLoadGlobalVar::mightAlias(MDefinition *def)
|
||||
{
|
||||
if (def->isAsmJSStoreGlobalVar()) {
|
||||
MAsmJSStoreGlobalVar *store = def->toAsmJSStoreGlobalVar();
|
||||
return store->globalDataOffset() == globalDataOffset_;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MAsmJSLoadGlobalVar::congruentTo(MDefinition *ins) const
|
||||
{
|
||||
if (ins->isAsmJSLoadGlobalVar()) {
|
||||
MAsmJSLoadGlobalVar *load = ins->toAsmJSLoadGlobalVar();
|
||||
return globalDataOffset_ == load->globalDataOffset_;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MLoadSlot::mightAlias(MDefinition *store)
|
||||
{
|
||||
|
@ -217,10 +217,11 @@ class AliasSet {
|
||||
FixedSlot = 1 << 3, // A member of obj->fixedSlots().
|
||||
TypedArrayElement = 1 << 4, // A typed array element.
|
||||
DOMProperty = 1 << 5, // A DOM property
|
||||
Last = DOMProperty,
|
||||
AsmJSGlobalVar = 1 << 6, // An asm.js global var
|
||||
Last = AsmJSGlobalVar,
|
||||
Any = Last | (Last - 1),
|
||||
|
||||
NumCategories = 6,
|
||||
NumCategories = 7,
|
||||
|
||||
// Indicates load or store.
|
||||
Store_ = 1 << 31
|
||||
@ -8446,8 +8447,7 @@ class MAsmJSLoadGlobalVar : public MNullaryInstruction
|
||||
{
|
||||
JS_ASSERT(type == MIRType_Int32 || type == MIRType_Double);
|
||||
setResultType(type);
|
||||
if (isConstant)
|
||||
setMovable();
|
||||
setMovable();
|
||||
}
|
||||
|
||||
unsigned globalDataOffset_;
|
||||
@ -8462,12 +8462,13 @@ class MAsmJSLoadGlobalVar : public MNullaryInstruction
|
||||
|
||||
unsigned globalDataOffset() const { return globalDataOffset_; }
|
||||
|
||||
bool congruentTo(MDefinition *ins) const;
|
||||
|
||||
AliasSet getAliasSet() const {
|
||||
if (isConstant_)
|
||||
return AliasSet::None();
|
||||
else
|
||||
return AliasSet::Store(AliasSet::Any);
|
||||
return AliasSet::Load(AliasSet::AsmJSGlobalVar);
|
||||
}
|
||||
|
||||
bool mightAlias(MDefinition *def);
|
||||
};
|
||||
|
||||
class MAsmJSStoreGlobalVar : public MUnaryInstruction
|
||||
@ -8487,6 +8488,10 @@ class MAsmJSStoreGlobalVar : public MUnaryInstruction
|
||||
|
||||
unsigned globalDataOffset() const { return globalDataOffset_; }
|
||||
MDefinition *value() const { return getOperand(0); }
|
||||
|
||||
AliasSet getAliasSet() const {
|
||||
return AliasSet::Store(AliasSet::AsmJSGlobalVar);
|
||||
}
|
||||
};
|
||||
|
||||
class MAsmJSLoadFuncPtr : public MUnaryInstruction
|
||||
|
Loading…
Reference in New Issue
Block a user