Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 23c373fa0b461e7a911ec9ac90a9575ea7f36feb..1ad750c8fc95dfb158d8d9be8b9bb690b5862346 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -5136,9 +5136,7 @@ void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
CHECK_ALIVE(VisitForValue(prop->obj())); |
HValue* object = Top(); |
HValue* key = NULL; |
- if ((!prop->IsStringLength() && |
- !prop->IsFunctionPrototype() && |
- !prop->key()->IsPropertyName()) || |
+ if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || |
prop->IsStringAccess()) { |
CHECK_ALIVE(VisitForValue(prop->key())); |
key = Top(); |
@@ -5828,17 +5826,20 @@ void HOptimizedGraphBuilder::PushLoad(Property* expr, |
} |
+static bool AreStringTypes(SmallMapList* types) { |
+ if (types == NULL || types->length() == 0) return false; |
+ for (int i = 0; i < types->length(); i++) { |
+ if (types->at(i)->instance_type() >= FIRST_NONSTRING_TYPE) return false; |
+ } |
+ return true; |
+} |
+ |
+ |
void HOptimizedGraphBuilder::BuildLoad(Property* expr, |
int position, |
BailoutId ast_id) { |
HInstruction* instr = NULL; |
- if (expr->IsStringLength()) { |
- HValue* string = Pop(); |
- BuildCheckHeapObject(string); |
- HInstruction* checkstring = |
- AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
- instr = BuildLoadStringLength(string, checkstring); |
- } else if (expr->IsStringAccess()) { |
+ if (expr->IsStringAccess()) { |
HValue* index = Pop(); |
HValue* string = Pop(); |
HValue* context = environment()->context(); |
@@ -5874,6 +5875,12 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr, |
} else { |
instr = BuildLoadNamedMonomorphic(Pop(), name, map); |
} |
+ } else if (AreStringTypes(types) && |
+ name->Equals(isolate()->heap()->length_string())) { |
+ Drop(1); |
+ BuildCheckHeapObject(object); |
+ HValue* checked_object = Add<HCheckMaps>(object, types); |
+ instr = BuildLoadStringLength(object, checked_object); |
} else if (types != NULL && types->length() > 1) { |
return HandlePolymorphicLoadNamedField( |
position, ast_id, Pop(), types, name); |
@@ -5914,9 +5921,7 @@ void HOptimizedGraphBuilder::VisitProperty(Property* expr) { |
if (TryArgumentsAccess(expr)) return; |
CHECK_ALIVE(VisitForValue(expr->obj())); |
- if ((!expr->IsStringLength() && |
- !expr->IsFunctionPrototype() && |
- !expr->key()->IsPropertyName()) || |
+ if ((!expr->IsFunctionPrototype() && !expr->key()->IsPropertyName()) || |
expr->IsStringAccess()) { |
CHECK_ALIVE(VisitForValue(expr->key())); |
} |
@@ -7567,9 +7572,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { |
HValue* object = Top(); |
HValue* key = NULL; |
- if ((!prop->IsStringLength() && |
- !prop->IsFunctionPrototype() && |
- !prop->key()->IsPropertyName()) || |
+ if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || |
prop->IsStringAccess()) { |
CHECK_ALIVE(VisitForValue(prop->key())); |
key = Top(); |