Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index be56c673b9ea8003bbac6fb15d28e5e5ae23156c..add82fdffe1e64c0f9bbd1a3a063e85c394a2c35 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -4762,10 +4762,17 @@ bool HGraphBuilder::TryCallApply(Call* expr) { |
Property* prop = callee->AsProperty(); |
ASSERT(prop != NULL); |
- if (info()->scope()->arguments() == NULL) return false; |
+ if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { |
+ return false; |
+ } |
+ Handle<Map> function_map = expr->GetReceiverTypes()->first(); |
+ if (function_map->instance_type() != JS_FUNCTION_TYPE || |
+ !expr->target()->shared()->HasBuiltinFunctionId() || |
+ expr->target()->shared()->builtin_function_id() != kFunctionApply) { |
+ return false; |
+ } |
- Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); |
- if (!name->IsEqualTo(CStrVector("apply"))) return false; |
+ if (info()->scope()->arguments() == NULL) return false; |
ZoneList<Expression*>* args = expr->arguments(); |
if (args->length() != 2) return false; |
@@ -4775,9 +4782,6 @@ bool HGraphBuilder::TryCallApply(Call* expr) { |
HValue* arg_two_value = environment()->Lookup(arg_two->var()); |
if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; |
- if (!expr->IsMonomorphic() || |
- expr->check_type() != RECEIVER_MAP_CHECK) return false; |
- |
// Our implementation of arguments (based on this stack frame or an |
// adapter below it) does not work for inlined functions. |
if (function_state()->outer() != NULL) { |
@@ -4794,10 +4798,7 @@ bool HGraphBuilder::TryCallApply(Call* expr) { |
HValue* receiver = Pop(); |
HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); |
HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); |
- AddCheckConstantFunction(expr, |
- function, |
- expr->GetReceiverTypes()->first(), |
- true); |
+ AddCheckConstantFunction(expr, function, function_map, true); |
HInstruction* result = |
new(zone()) HApplyArguments(function, receiver, length, elements); |
result->set_position(expr->position()); |