Index: src/ia32/fast-codegen-ia32.cc |
=================================================================== |
--- src/ia32/fast-codegen-ia32.cc (revision 3203) |
+++ src/ia32/fast-codegen-ia32.cc (working copy) |
@@ -787,29 +787,38 @@ |
void FastCodeGenerator::VisitCall(Call* expr) { |
+ Comment cmnt(masm_, "[ Call"); |
Expression* fun = expr->expression(); |
Variable* var = fun->AsVariableProxy()->AsVariable(); |
- if (var != NULL && |
- var->is_possibly_eval()) { |
- // Call to eval. |
+ if (var != NULL && var->is_possibly_eval()) { |
+ // Call to the identifier 'eval'. |
UNREACHABLE(); |
+ } else if (var != NULL && !var->is_this() && var->is_global()) { |
+ // Call to a global variable. |
+ __ push(Immediate(var->name())); |
+ // Push global object as receiver for the call IC lookup. |
+ __ push(CodeGenerator::GlobalObject()); |
+ EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); |
+ } else if (var != NULL && var->slot() != NULL && |
+ var->slot()->type() == Slot::LOOKUP) { |
+ // Call to a lookup slot. |
+ UNREACHABLE(); |
} else if (fun->AsProperty() != NULL) { |
- // Call on a property. |
+ // Call to an object property. |
Property* prop = fun->AsProperty(); |
Literal* key = prop->key()->AsLiteral(); |
if (key != NULL && key->handle()->IsSymbol()) { |
- // Call on a named property: foo.x(1,2,3) |
+ // Call to a named property, use call IC. |
__ push(Immediate(key->handle())); |
Visit(prop->obj()); |
- // Use call IC. |
EmitCallWithIC(expr, RelocInfo::CODE_TARGET); |
} else { |
- // Call on a keyed property: foo[key](1,2,3) |
- // Use a keyed load IC followed by a call IC. |
+ // Call to a keyed property, use keyed load IC followed by function |
+ // call. |
Visit(prop->obj()); |
Visit(prop->key()); |
- // Record source position of property. |
+ // Record source code position for IC call. |
SetSourcePosition(prop->position()); |
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
__ call(ic, RelocInfo::CODE_TARGET); |
@@ -830,22 +839,8 @@ |
} |
EmitCallWithStub(expr); |
} |
- } else if (var != NULL) { |
- // Call on a global variable |
- ASSERT(var != NULL); |
- ASSERT(!var->is_this()); |
- ASSERT(var->is_global()); |
- ASSERT(!var->is_possibly_eval()); |
- __ push(Immediate(var->name())); |
- // Push global object (receiver). |
- __ push(CodeGenerator::GlobalObject()); |
- EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); |
- } else if (var != NULL && var->slot() != NULL && |
- var->slot()->type() == Slot::LOOKUP) { |
- // Call inside a with-statement |
- UNREACHABLE(); |
} else { |
- // Call with an arbitrary function expression. |
+ // Call to some other function expression. |
Visit(expr->expression()); |
// Load global receiver object. |
__ mov(ebx, CodeGenerator::GlobalObject()); |