| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index 374e54c97389e448721421ca80898aeb6d42df1d..10623fb59db1ef8268f0c662a551f296b64bfefd 100644
|
| --- a/src/hydrogen.cc
|
| +++ b/src/hydrogen.cc
|
| @@ -7747,6 +7747,10 @@ static bool IsAllocationInlineable(Handle<JSFunction> constructor) {
|
| constructor->initial_map()->instance_size() < HAllocateObject::kMaxSize;
|
| }
|
|
|
| +static bool IsArrayConstructInlinable(Handle<JSFunction> constructor) {
|
| + return constructor->GetIsolate()->global_context()->array_function() ==
|
| + *constructor;
|
| +}
|
|
|
| void HGraphBuilder::VisitCallNew(CallNew* expr) {
|
| ASSERT(!HasStackOverflow());
|
| @@ -7795,6 +7799,30 @@ void HGraphBuilder::VisitCallNew(CallNew* expr) {
|
| new(zone()) HCallNew(context, function, argument_count));
|
| call->set_position(expr->position());
|
| return ast_context()->ReturnInstruction(call, expr->id());
|
| + } else if (expr->IsMonomorphic() &&
|
| + argument_count == 1 &&
|
| + IsArrayConstructInlinable(expr->target())) {
|
| + CHECK_ALIVE(VisitForValue(expr->expression()));
|
| + HValue* function = Top();
|
| + environment()->Drop(1);
|
| + Handle<JSFunction> constructor = expr->target();
|
| + ElementsKind elements_kind = expr->elements_kind();
|
| + AddInstruction(new(zone()) HCheckFunction(function, constructor));
|
| + Factory* f = graph()->isolate()->factory();
|
| + Handle<JSArray> boilerplate = f->NewEmptyJSArray(elements_kind, TENURED);
|
| + HValue* context = environment()->LookupContext();
|
| + int total_size = JSArray::kSize + FixedArray::kHeaderSize;
|
| + if (IsFastDoubleElementsKind(elements_kind)) {
|
| + total_size += boilerplate->elements()->length() * kDoubleSize;
|
| + } else {
|
| + total_size += boilerplate->elements()->length() * kPointerSize;
|
| + }
|
| + HFastLiteral* empty_array = new(zone()) HFastLiteral(context,
|
| + boilerplate,
|
| + total_size,
|
| + 0,
|
| + 0);
|
| + return ast_context()->ReturnInstruction(empty_array, expr->id());
|
| } else {
|
| // The constructor function is both an operand to the instruction and an
|
| // argument to the construct call.
|
|
|