Chromium Code Reviews| Index: src/x64/lithium-codegen-x64.cc |
| =================================================================== |
| --- src/x64/lithium-codegen-x64.cc (revision 11789) |
| +++ src/x64/lithium-codegen-x64.cc (working copy) |
| @@ -2233,6 +2233,18 @@ |
| } |
| +// Check for cases where EmitLoadFieldOrConstantFunction needs to walk the |
| +// prototype chain, which causes unbounded code generation. |
| +static bool CompactEmit( |
| + SmallMapList* list, Handle<String> name, int i, Isolate* isolate) { |
| + LookupResult lookup(isolate); |
| + Handle<Map> map = list->at(i); |
| + map->LookupInDescriptors(NULL, *name, &lookup); |
| + return lookup.IsFound() && |
| + (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION); |
| +} |
| + |
| + |
| void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
| Register object = ToRegister(instr->object()); |
| Register result = ToRegister(instr->result()); |
| @@ -2246,16 +2258,10 @@ |
| } |
| Handle<String> name = instr->hydrogen()->name(); |
| Label done; |
| - bool compact_code = true; |
| + bool all_are_compact = true; |
| for (int i = 0; i < map_count; ++i) { |
| - LookupResult lookup(isolate()); |
| - Handle<Map> map = instr->hydrogen()->types()->at(i); |
| - map->LookupInDescriptors(NULL, *name, &lookup); |
| - if (!lookup.IsFound() || |
| - (lookup.type() != FIELD && lookup.type() != CONSTANT_FUNCTION)) { |
| - // The two cases above cause a bounded amount of code to be emitted. This |
| - // is not necessarily the case for other lookup results. |
| - compact_code = false; |
| + if (!CompactEmit(instr->hydrogen()->types(), name, i, isolate())) { |
| + all_are_compact = false; |
| break; |
| } |
| } |
| @@ -2271,11 +2277,13 @@ |
| result, object, map, name, instr->environment()); |
| } else { |
| Label next; |
| - __ j(not_equal, &next, Label::kNear); |
| + bool compact = |
| + CompactEmit(instr->hydrogen()->types(), name, i, isolate()); |
|
Michael Starzinger
2012/06/13 09:49:57
This basically means we need to do three lookups (
|
| + __ j(not_equal, &next, compact ? Label::kNear : Label::kFar); |
| __ bind(&check_passed); |
| EmitLoadFieldOrConstantFunction( |
| result, object, map, name, instr->environment()); |
| - __ jmp(&done, compact_code ? Label::kNear: Label::kFar); |
| + __ jmp(&done, all_are_compact ? Label::kNear : Label::kFar); |
| __ bind(&next); |
| } |
| } |