return false;
}
- BuildArrayCall(expr,
- expr->arguments()->length(),
- function,
- expr->allocation_site());
+ Handle<AllocationSite> site = expr->allocation_site();
+ if (site.is_null()) return false;
+
+ BuildArrayCall(expr, expr->arguments()->length(), function, site);
return true;
}
// evaluation of the arguments.
CHECK_ALIVE(VisitForValue(expr->expression()));
HValue* function = Top();
- if (expr->global_call()) {
- Variable* var = proxy->var();
- bool known_global_function = false;
- // If there is a global property cell for the name at compile time and
- // access check is not enabled we assume that the function will not change
- // and generate optimized code for calling the function.
- Handle<GlobalObject> global(current_info()->global_object());
- LookupIterator it(global, var->name(),
- LookupIterator::OWN_SKIP_INTERCEPTOR);
- GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD);
- if (type == kUseCell) {
- known_global_function = expr->ComputeGlobalTarget(global, &it);
- }
- if (known_global_function) {
- Add<HCheckValue>(function, expr->target());
-
- // Placeholder for the receiver.
- Push(graph()->GetConstantUndefined());
- CHECK_ALIVE(VisitExpressions(expr->arguments()));
-
- // Patch the global object on the stack by the expected receiver.
- HValue* receiver = ImplicitReceiverFor(function, expr->target());
- const int receiver_index = argument_count - 1;
- environment()->SetExpressionStackAt(receiver_index, receiver);
-
- if (TryInlineBuiltinFunctionCall(expr)) {
- if (FLAG_trace_inlining) {
- PrintF("Inlining builtin ");
- expr->target()->ShortPrint();
- PrintF("\n");
- }
- return;
- }
- if (TryInlineApiFunctionCall(expr, receiver)) return;
- if (TryHandleArrayCall(expr, function)) return;
- if (TryInlineCall(expr)) return;
+ if (function->IsConstant() &&
+ HConstant::cast(function)->handle(isolate())->IsJSFunction()) {
+ Handle<Object> constant = HConstant::cast(function)->handle(isolate());
+ Handle<JSFunction> target = Handle<JSFunction>::cast(constant);
+ expr->SetKnownGlobalTarget(target);
+ }
- PushArgumentsFromEnvironment(argument_count);
- call = BuildCallConstantFunction(expr->target(), argument_count);
- } else {
- Push(graph()->GetConstantUndefined());
- CHECK_ALIVE(VisitExpressions(expr->arguments()));
- PushArgumentsFromEnvironment(argument_count);
- call = New<HCallFunction>(function, argument_count);
- }
+ // Placeholder for the receiver.
+ Push(graph()->GetConstantUndefined());
+ CHECK_ALIVE(VisitExpressions(expr->arguments()));
- } else if (expr->IsMonomorphic()) {
+ if (expr->IsMonomorphic()) {
Add<HCheckValue>(function, expr->target());
- Push(graph()->GetConstantUndefined());
- CHECK_ALIVE(VisitExpressions(expr->arguments()));
-
+ // Patch the global object on the stack by the expected receiver.
HValue* receiver = ImplicitReceiverFor(function, expr->target());
const int receiver_index = argument_count - 1;
environment()->SetExpressionStackAt(receiver_index, receiver);
return;
}
if (TryInlineApiFunctionCall(expr, receiver)) return;
-
+ if (TryHandleArrayCall(expr, function)) return;
if (TryInlineCall(expr)) return;
- call = PreProcessCall(New<HInvokeFunction>(
- function, expr->target(), argument_count));
-
+ PushArgumentsFromEnvironment(argument_count);
+ call = BuildCallConstantFunction(expr->target(), argument_count);
} else {
- Push(graph()->GetConstantUndefined());
- CHECK_ALIVE(VisitExpressions(expr->arguments()));
PushArgumentsFromEnvironment(argument_count);
HCallFunction* call_function =
New<HCallFunction>(function, argument_count);
HValue* function = Top();
CHECK_ALIVE(VisitExpressions(expr->arguments()));
+ if (function->IsConstant() &&
+ HConstant::cast(function)->handle(isolate())->IsJSFunction()) {
+ Handle<Object> constant = HConstant::cast(function)->handle(isolate());
+ expr->SetKnownGlobalTarget(Handle<JSFunction>::cast(constant));
+ }
+
if (FLAG_inline_construct &&
expr->IsMonomorphic() &&
IsAllocationInlineable(expr->target())) {