Reviewers: Søren Gjesse,

Description:
Implement %_CallFunction in hydrogen.

Please review this at http://codereview.chromium.org/6084003/

Affected files:
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 86b10363dcab101c1fb86a7a7d4be746a5318a72..9855c877618271f6991654554a9c09574a4b7dd8 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4284,12 +4284,6 @@ void HGraphBuilder::VisitCall(Call* expr) {
     Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
bool global_call = (var != NULL) && var->is_global() && !var->is_this();

-    if (!global_call) {
-      ++argument_count;
-      VisitArgument(expr->expression());
-      CHECK_BAILOUT;
-    }
-
     if (global_call) {
// 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
@@ -4344,8 +4338,12 @@ void HGraphBuilder::VisitCall(Call* expr) {

         call = new HCallGlobal(var->name(), argument_count);
       }
-
     } else {
+      // Non-global call.
+      ++argument_count;
+      VisitArgument(expr->expression());
+      CHECK_BAILOUT;
+
       PushAndAdd(new HGlobalReceiver);
       VisitArgumentList(expr->arguments());
       CHECK_BAILOUT;
@@ -5145,7 +5143,18 @@ void HGraphBuilder::GenerateSwapElements(int argument_count, int ast_id) {

 // Fast call for custom callbacks.
 void HGraphBuilder::GenerateCallFunction(int argument_count, int ast_id) {
-  BAILOUT("inlined runtime function: CallFunction");
+  // BAILOUT("boo");
+  ASSERT(argument_count >= 2);
+  // Move function from top of stack to below arguments.
+  HValue* function = Pop();
+  int argc = argument_count - 1;  // Don't count the function itself.
+  SmartPointer<HValue*> arguments(NewArray<HValue*>(argc));
+  for (int i = 0; i < argc; i++) { arguments[i] = Pop(); }
+  Push(function);
+  for (int i = argc - 1; i >= 0; i--) { Push(arguments[i]); }
+  HCallFunction* result = new HCallFunction(argument_count);
+  ProcessCall(result);
+  ast_context()->ReturnInstruction(result, ast_id);
 }




--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to