Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: runtime/vm/constant_propagator.cc

Issue 2897803002: VM: Constant fold more loads from constants in the optimizer. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/constant_propagator.cc
diff --git a/runtime/vm/constant_propagator.cc b/runtime/vm/constant_propagator.cc
index 7aa02f1e376ba6a70f2ee5eb4a0ef7595a7620bc..2792f822b99d715c8089b47f203dcbfac2addc27 100644
--- a/runtime/vm/constant_propagator.cc
+++ b/runtime/vm/constant_propagator.cc
@@ -831,30 +831,33 @@ void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) {
}
}
- if (instr->IsImmutableLengthLoad()) {
- ConstantInstr* constant =
- instance->definition()->OriginalDefinition()->AsConstant();
- if (constant != NULL) {
- if (constant->value().IsString()) {
+ const Object& constant = instance->definition()->constant_value();
+ if (IsConstant(constant)) {
+ if (instr->IsImmutableLengthLoad()) {
+ if (constant.IsString()) {
SetValue(instr,
- Smi::ZoneHandle(
- Z, Smi::New(String::Cast(constant->value()).Length())));
+ Smi::ZoneHandle(Z, Smi::New(String::Cast(constant).Length())));
return;
}
- if (constant->value().IsArray()) {
+ if (constant.IsArray()) {
SetValue(instr,
- Smi::ZoneHandle(
- Z, Smi::New(Array::Cast(constant->value()).Length())));
+ Smi::ZoneHandle(Z, Smi::New(Array::Cast(constant).Length())));
return;
}
- if (constant->value().IsTypedData()) {
- SetValue(instr,
- Smi::ZoneHandle(
- Z, Smi::New(TypedData::Cast(constant->value()).Length())));
+ if (constant.IsTypedData()) {
+ SetValue(instr, Smi::ZoneHandle(
+ Z, Smi::New(TypedData::Cast(constant).Length())));
+ return;
+ }
+ } else {
+ Object& value = Object::Handle();
+ if (instr->Evaluate(constant, &value)) {
+ SetValue(instr, Object::ZoneHandle(Z, value.raw()));
return;
}
}
}
+
SetValue(instr, non_constant_);
}
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698