Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Unified Diff: src/hydrogen.cc

Issue 1023103003: If CallNew targets a constant global, set its state to monomorphic (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 6f349b79c4a1eac2e3b9ec332f49d63bd93071e7..79c8e03d664142b209171f0a59d756909e0d71f5 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -9105,10 +9105,10 @@ bool HOptimizedGraphBuilder::TryHandleArrayCallNew(CallNew* expr,
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;
}
@@ -9230,58 +9230,21 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
// 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);
@@ -9295,15 +9258,12 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
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);
@@ -9442,6 +9402,12 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
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())) {
« no previous file with comments | « src/ast.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698