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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 560113002: Narrow String::CharAt from int32_t to uint16_t. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index bc6ff54c98e56167d4832e71e8f93cf8d77bbd6b..8a6cff9621cb6d7117a7e38949731f4e835412c7 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -1847,7 +1847,7 @@ bool FlowGraphOptimizer::TryStringLengthOneEquality(InstanceCallInstr* call,
const String& str = String::Cast(left_const->value());
ASSERT(str.Length() == 1);
ConstantInstr* char_code_left = flow_graph()->GetConstant(
- Smi::ZoneHandle(I, Smi::New(str.CharAt(0))));
+ Smi::ZoneHandle(I, Smi::New(static_cast<intptr_t>(str.CharAt(0)))));
left_val = new(I) Value(char_code_left);
} else if (left->IsStringFromCharCode()) {
// Use input of string-from-charcode as left value.
@@ -8013,7 +8013,8 @@ void ConstantPropagator::VisitStringToCharCode(StringToCharCodeInstr* instr) {
SetValue(instr, non_constant_);
} else if (IsConstant(o)) {
const String& str = String::Cast(o);
- const intptr_t result = (str.Length() == 1) ? str.CharAt(0) : -1;
+ const intptr_t result =
+ (str.Length() == 1) ? static_cast<intptr_t>(str.CharAt(0)) : -1;
SetValue(instr, Smi::ZoneHandle(I, Smi::New(result)));
}
}
@@ -8044,7 +8045,8 @@ void ConstantPropagator::VisitLoadIndexed(LoadIndexedInstr* instr) {
if (array_obj.IsString()) {
const String& str = String::Cast(array_obj);
if (str.Length() > index) {
- SetValue(instr, Smi::Handle(I, Smi::New(str.CharAt(index))));
+ SetValue(instr, Smi::Handle(I,
+ Smi::New(static_cast<intptr_t>(str.CharAt(index)))));
return;
}
} else if (array_obj.IsArray()) {
« runtime/lib/string.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698