Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index ead56a494700d8c70664400fcfdbec99eb61a352..f4b6d039cb5aa11fef0a59b8b4a5e29237cd5447 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -7659,6 +7659,41 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( |
Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); |
return true; |
} |
+ case kArrayPush: { |
+ if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { |
+ return false; |
+ } |
+ if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
+ ElementsKind elements_kind = receiver_map->elements_kind(); |
+ if (!IsFastElementsKind(elements_kind)) return false; |
+ AddCheckConstantFunction(expr->holder(), receiver, receiver_map); |
+ |
+ HValue* op_vals[] = { |
+ context(), |
+ // Receiver. |
+ environment()->ExpressionStackAt(expr->arguments()->length()) |
+ }; |
+ |
+ const int argc = expr->arguments()->length(); |
+ // Includes receiver. |
+ PushArgumentsFromEnvironment(argc + 1); |
+ |
+ CallInterfaceDescriptor* descriptor = |
+ isolate()->call_descriptor(Isolate::CallHandler); |
+ |
+ ArrayPushStub stub(receiver_map->elements_kind(), argc); |
+ Handle<Code> code = stub.GetCode(isolate()); |
+ HConstant* code_value = Add<HConstant>(code); |
+ |
+ ASSERT((sizeof(op_vals) / kPointerSize) == |
+ descriptor->environment_length()); |
+ |
+ HInstruction* call = New<HCallWithDescriptor>( |
+ code_value, argc + 1, descriptor, |
+ Vector<HValue*>(op_vals, descriptor->environment_length())); |
+ ast_context()->ReturnInstruction(call, expr->id()); |
+ return true; |
+ } |
default: |
// Not yet supported for inlining. |
break; |