Enable GVN on HForeignNew

R=sigmund@google.com

Review URL: https://codereview.chromium.org/2422003002 .
This commit is contained in:
Stephen Adams 2016-10-14 17:34:07 -07:00
parent 997581ccec
commit 790b9d9cb1
2 changed files with 13 additions and 2 deletions

View file

@ -873,6 +873,8 @@ abstract class HInstruction implements Spannable {
static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39;
static const int TYPE_INFO_EXPRESSION_TYPECODE = 40;
static const int FOREIGN_CODE_TYPECODE = 41;
HInstruction(this.inputs, this.instructionType)
: id = idCounter++,
usedBy = <HInstruction>[] {
@ -1901,6 +1903,9 @@ class HForeignCode extends HForeign {
assert(this.throwBehavior != null);
if (effects != null) sideEffects.add(effects);
if (nativeBehavior != null && nativeBehavior.useGvn) {
setUseGvn();
}
}
HForeignCode.statement(js.Template codeTemplate, List<HInstruction> inputs,
@ -1927,7 +1932,13 @@ class HForeignCode extends HForeign {
bool get isAllocation =>
nativeBehavior != null && nativeBehavior.isAllocation && !canBeNull();
String toString() => 'HForeignCode("${codeTemplate.source}",$inputs)';
int typeCode() => HInstruction.FOREIGN_CODE_TYPECODE;
bool typeEquals(other) => other is HForeignCode;
bool dataEquals(HForeignCode other) {
return codeTemplate.source == other.codeTemplate.source;
}
String toString() => 'HForeignCode("${codeTemplate.source}", $inputs)';
}
abstract class HInvokeBinary extends HInstruction {

View file

@ -56,7 +56,7 @@ class JSNumber extends Interceptor implements num {
return JS('num', r'# % #', this, b);
}
num abs() => JS('returns:num;effects:none;depends:none;throws:never',
num abs() => JS('returns:num;effects:none;depends:none;throws:never;gvn:true',
r'Math.abs(#)', this);
num get sign => this > 0 ? 1 : this < 0 ? -1 : this;