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

Unified Diff: src/hydrogen.cc

Issue 7623016: Merge r8884 "Fix fun.apply(receiver, arguments) optimization" to 3.4 (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.4/
Patch Set: Created 9 years, 4 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/hydrogen.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
===================================================================
--- src/hydrogen.cc (revision 8902)
+++ src/hydrogen.cc (working copy)
@@ -4777,11 +4777,18 @@
Property* prop = callee->AsProperty();
ASSERT(prop != NULL);
+ if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
+ return false;
+ }
+ Handle<Map> function_map = expr->GetReceiverTypes()->first();
+ if (function_map->instance_type() != JS_FUNCTION_TYPE ||
+ !expr->target()->shared()->HasBuiltinFunctionId() ||
+ expr->target()->shared()->builtin_function_id() != kFunctionApply) {
+ return false;
+ }
+
if (info()->scope()->arguments() == NULL) return false;
- Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
- if (!name->IsEqualTo(CStrVector("apply"))) return false;
-
ZoneList<Expression*>* args = expr->arguments();
if (args->length() != 2) return false;
@@ -4790,9 +4797,6 @@
HValue* arg_two_value = environment()->Lookup(arg_two->var());
if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false;
- if (!expr->IsMonomorphic() ||
- expr->check_type() != RECEIVER_MAP_CHECK) return false;
-
// Our implementation of arguments (based on this stack frame or an
// adapter below it) does not work for inlined functions.
if (function_state()->outer() != NULL) {
@@ -4809,10 +4813,7 @@
HValue* receiver = Pop();
HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements));
- AddCheckConstantFunction(expr,
- function,
- expr->GetReceiverTypes()->first(),
- true);
+ AddCheckConstantFunction(expr, function, function_map, true);
HInstruction* result =
new(zone()) HApplyArguments(function, receiver, length, elements);
result->set_position(expr->position());
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698