| Index: src/hydrogen.cc
|
| ===================================================================
|
| --- src/hydrogen.cc (revision 8462)
|
| +++ src/hydrogen.cc (working copy)
|
| @@ -2179,9 +2179,12 @@
|
| }
|
|
|
|
|
| -void HGraphBuilder::VisitArgument(Expression* expr) {
|
| - CHECK_ALIVE(VisitForValue(expr));
|
| - Push(AddInstruction(new(zone()) HPushArgument(Pop())));
|
| +HValue* HGraphBuilder::VisitArgument(Expression* expr) {
|
| + VisitForValue(expr);
|
| + if (HasStackOverflow() || current_block() == NULL) return NULL;
|
| + HValue* value = Pop();
|
| + Push(AddInstruction(new(zone()) HPushArgument(value)));
|
| + return value;
|
| }
|
|
|
|
|
| @@ -4449,7 +4452,6 @@
|
| HEnvironment* inner_env =
|
| environment()->CopyForInlining(target,
|
| function,
|
| - HEnvironment::HYDROGEN,
|
| undefined,
|
| call_kind);
|
| HBasicBlock* body_entry = CreateBasicBlock(inner_env);
|
| @@ -4692,7 +4694,7 @@
|
| if (prop != NULL) {
|
| if (!prop->key()->IsPropertyName()) {
|
| // Keyed function call.
|
| - CHECK_ALIVE(VisitForValue(prop->obj()));
|
| + CHECK_ALIVE(VisitArgument(prop->obj()));
|
|
|
| CHECK_ALIVE(VisitForValue(prop->key()));
|
| // Push receiver and key like the non-optimized code generator expects it.
|
| @@ -4701,13 +4703,12 @@
|
| Push(key);
|
| Push(receiver);
|
|
|
| - CHECK_ALIVE(VisitExpressions(expr->arguments()));
|
| + CHECK_ALIVE(VisitArgumentList(expr->arguments()));
|
|
|
| HValue* context = environment()->LookupContext();
|
| - call = PreProcessCall(
|
| - new(zone()) HCallKeyed(context, key, argument_count));
|
| + call = new(zone()) HCallKeyed(context, key, argument_count);
|
| call->set_position(expr->position());
|
| - Drop(1); // Key.
|
| + Drop(argument_count + 1); // 1 is the key.
|
| ast_context()->ReturnInstruction(call, expr->id());
|
| return;
|
| }
|
| @@ -4767,11 +4768,6 @@
|
| Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
|
| bool global_call = (var != NULL) && var->is_global() && !var->is_this();
|
|
|
| - if (!global_call) {
|
| - ++argument_count;
|
| - CHECK_ALIVE(VisitForValue(expr->expression()));
|
| - }
|
| -
|
| if (global_call) {
|
| bool known_global_function = false;
|
| // If there is a global property cell for the name at compile time and
|
| @@ -4811,22 +4807,29 @@
|
| argument_count));
|
| } else {
|
| HValue* context = environment()->LookupContext();
|
| - PushAndAdd(new(zone()) HGlobalObject(context));
|
| - CHECK_ALIVE(VisitExpressions(expr->arguments()));
|
| + HGlobalObject* receiver = new(zone()) HGlobalObject(context);
|
| + AddInstruction(receiver);
|
| + PushAndAdd(new(zone()) HPushArgument(receiver));
|
| + CHECK_ALIVE(VisitArgumentList(expr->arguments()));
|
|
|
| - call = PreProcessCall(new(zone()) HCallGlobal(context,
|
| - var->name(),
|
| - argument_count));
|
| + call = new(zone()) HCallGlobal(context, var->name(), argument_count);
|
| + Drop(argument_count);
|
| }
|
|
|
| } else {
|
| + CHECK_ALIVE(VisitArgument(expr->expression()));
|
| HValue* context = environment()->LookupContext();
|
| HGlobalObject* global_object = new(zone()) HGlobalObject(context);
|
| + HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global_object);
|
| AddInstruction(global_object);
|
| - PushAndAdd(new(zone()) HGlobalReceiver(global_object));
|
| - CHECK_ALIVE(VisitExpressions(expr->arguments()));
|
| + AddInstruction(receiver);
|
| + PushAndAdd(new(zone()) HPushArgument(receiver));
|
| + CHECK_ALIVE(VisitArgumentList(expr->arguments()));
|
|
|
| - call = PreProcessCall(new(zone()) HCallFunction(context, argument_count));
|
| + // The function to call is treated as an argument to the call function
|
| + // stub.
|
| + call = new(zone()) HCallFunction(context, argument_count + 1);
|
| + Drop(argument_count + 1);
|
| }
|
| }
|
|
|
| @@ -4841,18 +4844,18 @@
|
| ASSERT(current_block()->HasPredecessor());
|
| // The constructor function is also used as the receiver argument to the
|
| // JS construct call builtin.
|
| - CHECK_ALIVE(VisitForValue(expr->expression()));
|
| - CHECK_ALIVE(VisitExpressions(expr->arguments()));
|
| + HValue* constructor = NULL;
|
| + CHECK_ALIVE(constructor = VisitArgument(expr->expression()));
|
| + CHECK_ALIVE(VisitArgumentList(expr->arguments()));
|
|
|
| HValue* context = environment()->LookupContext();
|
|
|
| // The constructor is both an operand to the instruction and an argument
|
| // to the construct call.
|
| int arg_count = expr->arguments()->length() + 1; // Plus constructor.
|
| - HValue* constructor = environment()->ExpressionStackAt(arg_count - 1);
|
| HCallNew* call = new(zone()) HCallNew(context, constructor, arg_count);
|
| call->set_position(expr->position());
|
| - PreProcessCall(call);
|
| + Drop(arg_count);
|
| ast_context()->ReturnInstruction(call, expr->id());
|
| }
|
|
|
| @@ -6212,7 +6215,6 @@
|
| HEnvironment* HEnvironment::CopyForInlining(
|
| Handle<JSFunction> target,
|
| FunctionLiteral* function,
|
| - CompilationPhase compilation_phase,
|
| HConstant* undefined,
|
| CallKind call_kind) const {
|
| // Outer environment is a copy of this one without the arguments.
|
| @@ -6224,17 +6226,9 @@
|
| HEnvironment* inner =
|
| new(zone) HEnvironment(outer, function->scope(), target);
|
| // Get the argument values from the original environment.
|
| - if (compilation_phase == HYDROGEN) {
|
| - for (int i = 0; i <= arity; ++i) { // Include receiver.
|
| - HValue* push = ExpressionStackAt(arity - i);
|
| - inner->SetValueAt(i, push);
|
| - }
|
| - } else {
|
| - ASSERT(compilation_phase == LITHIUM);
|
| - for (int i = 0; i <= arity; ++i) { // Include receiver.
|
| - HValue* push = ExpressionStackAt(arity - i);
|
| - inner->SetValueAt(i, push);
|
| - }
|
| + for (int i = 0; i <= arity; ++i) { // Include receiver.
|
| + HValue* push = ExpressionStackAt(arity - i);
|
| + inner->SetValueAt(i, push);
|
| }
|
| // If the function we are inlining is a strict mode function or a
|
| // builtin function, pass undefined as the receiver for function
|
|
|