Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 206ab7e2accf5e496b6cd814eb1071c511cb21e7..02abf0bbd0c7fd231629f8a103536a8be1900095 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -3991,6 +3991,26 @@ HInstruction* HShr::New( |
} |
+HInstruction* HSeqStringGetChar::New(Zone* zone, |
+ HValue* context, |
+ String::Encoding encoding, |
+ HValue* string, |
+ HValue* index) { |
+ if (FLAG_fold_constants && string->IsConstant() && index->IsConstant()) { |
+ HConstant* c_string = HConstant::cast(string); |
+ HConstant* c_index = HConstant::cast(index); |
+ if (c_string->HasStringValue() && c_index->HasInteger32Value()) { |
+ Handle<String> s = c_string->StringValue(); |
+ int32_t i = c_index->Integer32Value(); |
+ ASSERT_LE(0, i); |
+ ASSERT_LT(i, s->length()); |
+ return H_CONSTANT_INT(s->Get(i)); |
+ } |
+ } |
+ return new(zone) HSeqStringGetChar(encoding, string, index); |
+} |
+ |
+ |
#undef H_CONSTANT_INT |
#undef H_CONSTANT_DOUBLE |