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

Unified Diff: runtime/vm/constant_propagator.cc

Issue 2897603002: 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 050c0ba2a99606affbf530fab27dbd375b478f8f..3e3831dda45310a7c86d3244ea7c3df0500da0ce 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