Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index 8499b9925eaee3523628d2352cfdfc5ad2c626b6..ca728be0c70564523c132697d698e18450eb42c7 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -1050,6 +1050,11 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( |
| elements_kind, is_store); |
| } |
| +HInstruction* HGraphBuilder::BuildFastArrayLengthLoad(HValue* object) { |
| + Zone* zone = this->zone(); |
| + return new (zone) HJSArrayLength(object, NULL, HType::Smi()); |
| +} |
| + |
| HValue* HGraphBuilder::BuildAllocateElements(HContext* context, |
| ElementsKind kind, |
| @@ -6734,6 +6739,15 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
| Handle<Map> map) { |
| // Handle a load from a known field. |
| ASSERT(!map->is_dictionary_map()); |
| + |
| + // Handle access to various length properties |
| + if (name->Equals(isolate()->heap()->length_string())) { |
| + if (map->instance_type() == JS_ARRAY_TYPE) { |
| + AddCheckMapsWithTransitions(object, map); |
|
danno
2013/03/13 11:49:48
I think with your changes, you may not need WithTr
Dmitry Lomov (no reviews)
2013/03/13 16:14:31
Done.
|
| + return BuildFastArrayLengthLoad(object); |
| + } |
| + } |
| + |
| LookupResult lookup(isolate()); |
| map->LookupDescriptor(NULL, *name, &lookup); |
| if (lookup.IsField()) { |
| @@ -7220,13 +7234,7 @@ void HOptimizedGraphBuilder::VisitProperty(Property* expr) { |
| CHECK_ALIVE(VisitForValue(expr->obj())); |
| HInstruction* instr = NULL; |
| - if (expr->AsProperty()->IsArrayLength()) { |
| - HValue* array = Pop(); |
| - AddInstruction(new(zone()) HCheckNonSmi(array)); |
| - HInstruction* mapcheck = |
| - AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone())); |
| - instr = new(zone()) HJSArrayLength(array, mapcheck); |
| - } else if (expr->IsStringLength()) { |
| + if (expr->IsStringLength()) { |
| HValue* string = Pop(); |
| AddInstruction(new(zone()) HCheckNonSmi(string)); |
| AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |