Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index ba1de7aa2258a308927c90f937d5d1e6beccd841..f32e0cd2120812eb837594e8132bc5eab1adce02 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -1748,32 +1748,48 @@ void HGraphBuilder::BuildCompareNil( |
| HIfContinuation* continuation) { |
| IfBuilder if_nil(this, position); |
| bool needs_or = false; |
| - if (type->Maybe(Type::Null())) { |
| - if (needs_or) if_nil.Or(); |
| - if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); |
| - needs_or = true; |
| - } |
| - if (type->Maybe(Type::Undefined())) { |
| - if (needs_or) if_nil.Or(); |
| - if_nil.If<HCompareObjectEqAndBranch>(value, |
| - graph()->GetConstantUndefined()); |
| - needs_or = true; |
| - } |
| - if (type->Maybe(Type::Undetectable())) { |
| - if (needs_or) if_nil.Or(); |
| - if_nil.If<HIsUndetectableAndBranch>(value); |
| + if (value->IsConstant()) { |
| + bool is_null = false; |
| + HConstant* constant_value = HConstant::cast(value); |
| + if (!constant_value->HasNumberValue()) { |
| + Object* constant_object = *(constant_value->handle()); |
|
Jakob Kummerow
2013/08/14 15:45:20
nit: let's just keep this handlified, i.e.:
Handle
|
| + is_null = constant_object->IsNull() || |
| + constant_object->IsUndefined() || |
| + constant_object->IsUndetectableObject(); |
| + } |
| + constant_value = is_null |
| + ? graph()->GetConstantTrue() |
| + : graph()->GetConstantFalse(); |
| + if_nil.If<HCompareObjectEqAndBranch>(constant_value, |
| + graph()->GetConstantTrue()); |
| } else { |
| - if_nil.Then(); |
| - if_nil.Else(); |
| - if (type->NumClasses() == 1) { |
| - BuildCheckHeapObject(value); |
| - // For ICs, the map checked below is a sentinel map that gets replaced by |
| - // the monomorphic map when the code is used as a template to generate a |
| - // new IC. For optimized functions, there is no sentinel map, the map |
| - // emitted below is the actual monomorphic map. |
| - BuildCheckMap(value, type->Classes().Current()); |
| + if (type->Maybe(Type::Null())) { |
| + if (needs_or) if_nil.Or(); |
| + if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); |
| + needs_or = true; |
| + } |
| + if (type->Maybe(Type::Undefined())) { |
| + if (needs_or) if_nil.Or(); |
| + if_nil.If<HCompareObjectEqAndBranch>(value, |
| + graph()->GetConstantUndefined()); |
| + needs_or = true; |
| + } |
| + if (type->Maybe(Type::Undetectable())) { |
| + if (needs_or) if_nil.Or(); |
| + if_nil.If<HIsUndetectableAndBranch>(value); |
| } else { |
| - if_nil.Deopt("Too many undetectable types"); |
| + if_nil.Then(); |
| + if_nil.Else(); |
| + if (type->NumClasses() == 1) { |
| + BuildCheckHeapObject(value); |
| + // For ICs, the map checked below is a sentinel map that gets replaced |
| + // by the monomorphic map when the code is used as a template to |
| + // generate a new IC. For optimized functions, there is no sentinel map, |
| + // the map emitted below is the actual monomorphic map. |
| + BuildCheckMap(value, type->Classes().Current()); |
| + } else { |
| + if_nil.Deopt("Too many undetectable types"); |
| + } |
| } |
| } |