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

Unified Diff: src/hydrogen.cc

Issue 1066873002: Simplify instanceof optimization; don't duplicate lookup (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update comment Created 5 years, 8 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 | « no previous file | 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 038834ca442daf22093bdb21e556920527364016..029cd808e22c1a6395e4d75a5d9084e97761c0c0 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -10828,41 +10828,19 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
}
if (op == Token::INSTANCEOF) {
- // Check to see if the rhs of the instanceof is a global function not
- // residing in new space. If it is we assume that the function will stay the
- // same.
- Handle<JSFunction> target = Handle<JSFunction>::null();
- VariableProxy* proxy = expr->right()->AsVariableProxy();
- bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated();
- if (global_function && current_info()->has_global_object()) {
- Handle<String> name = proxy->name();
- Handle<GlobalObject> global(current_info()->global_object());
- LookupIterator it(global, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
- Handle<Object> value = JSObject::GetDataProperty(&it);
- if (it.IsFound() && value->IsJSFunction()) {
- Handle<JSFunction> candidate = Handle<JSFunction>::cast(value);
- // If the function is in new space we assume it's more likely to
- // change and thus prefer the general IC code.
- if (!isolate()->heap()->InNewSpace(*candidate)) {
- target = candidate;
- }
- }
- }
-
- // If the target is not null we have found a known global function that is
- // assumed to stay the same for this instanceof.
- if (target.is_null()) {
- HInstanceOf* result = New<HInstanceOf>(left, right);
- return ast_context()->ReturnInstruction(result, expr->id());
- } else {
- Add<HCheckValue>(right, target);
+ // Check to see if the rhs of the instanceof is a known function.
+ if (right->IsConstant() &&
+ HConstant::cast(right)->handle(isolate())->IsJSFunction()) {
+ Handle<Object> function = HConstant::cast(right)->handle(isolate());
+ Handle<JSFunction> target = Handle<JSFunction>::cast(function);
HInstanceOfKnownGlobal* result =
- New<HInstanceOfKnownGlobal>(left, target);
+ New<HInstanceOfKnownGlobal>(left, target);
return ast_context()->ReturnInstruction(result, expr->id());
}
- // Code below assumes that we don't fall through.
- UNREACHABLE();
+ HInstanceOf* result = New<HInstanceOf>(left, right);
+ return ast_context()->ReturnInstruction(result, expr->id());
+
} else if (op == Token::IN) {
HValue* function = AddLoadJSBuiltin(Builtins::IN);
Add<HPushArguments>(left, right);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698