Chromium Code Reviews| Index: src/ia32/full-codegen-ia32.cc |
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
| index 59c3373866b9dfe413836a33151cd5547b08b07b..afb4a8928e5fd3d2b192dbf77eb65b10d1dd5fe4 100644 |
| --- a/src/ia32/full-codegen-ia32.cc |
| +++ b/src/ia32/full-codegen-ia32.cc |
| @@ -130,6 +130,20 @@ void FullCodeGenerator::Generate(CompilationInfo* info) { |
| } |
| #endif |
| + // Strict mode functions need to replace the receiver with undefined |
| + // when called with an implicit receiver. ecx is zero for explicit |
| + // receiver calls and one for implicit receiver calls. |
| + if (info->is_strict_mode()) { |
| + Label ok; |
| + __ test(ecx, Operand(ecx)); |
| + __ j(zero, &ok, Label::kNear); |
| + // +1 for return address. |
| + int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; |
| + __ mov(Operand(esp, receiver_offset), |
| + Immediate(isolate()->factory()->undefined_value())); |
| + __ bind(&ok); |
| + } |
| + |
| __ push(ebp); // Caller's frame pointer. |
| __ mov(ebp, esp); |
| __ push(esi); // Callee's context. |
| @@ -2044,8 +2058,8 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, |
| // Record source position of the IC call. |
| SetSourcePosition(expr->position()); |
| InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| - Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize( |
| - arg_count, in_loop); |
| + Handle<Code> ic = |
| + isolate()->stub_cache()->ComputeCallInitialize(arg_count, in_loop, mode); |
| EmitCallIC(ic, mode, expr->id()); |
| RecordJSReturnSite(expr); |
| // Restore context register. |
| @@ -2055,8 +2069,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, |
| void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
| - Expression* key, |
| - RelocInfo::Mode mode) { |
| + Expression* key) { |
| // Load the key. |
| VisitForAccumulatorValue(key); |
| @@ -2080,7 +2093,7 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
| Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize( |
| arg_count, in_loop); |
| __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. |
| - EmitCallIC(ic, mode, expr->id()); |
| + EmitCallIC(ic, RelocInfo::CODE_TARGET, expr->id()); |
| RecordJSReturnSite(expr); |
| // Restore context register. |
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| @@ -2191,7 +2204,9 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
| // Record source position for debugger. |
| SetSourcePosition(expr->position()); |
| InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| - CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE); |
| + CallFunctionStub stub(arg_count, |
| + in_loop, |
| + NON_VALUE_RECEIVER_MIGHT_BE_IMPLICIT); |
|
Kevin Millikin (Chromium)
2011/05/18 15:57:23
Why not MIGHT_BE_VALUE | MIGHT_BE_IMPLICIT? Don't
Mads Ager (chromium)
2011/05/23 16:31:34
Yes, this does dodge the value check. I convinced
|
| __ CallStub(&stub); |
| RecordJSReturnSite(expr); |
| // Restore context register. |
| @@ -2239,9 +2254,10 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
| __ bind(&call); |
| } |
| - // The receiver is either the global receiver or a JSObject found by |
| - // LoadContextSlot. |
| - EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
| + // The receiver is either the global receiver or an object found |
| + // by LoadContextSlot. That object could be the hole if the |
| + // receiver is implicitly the global object. |
| + EmitCallWithStub(expr, RECEIVER_MIGHT_BE_VALUE); |
|
Kevin Millikin (Chromium)
2011/05/18 15:57:23
Why MIGHT_BE_VALUE? It wasn't before, but I can s
Mads Ager (chromium)
2011/05/23 16:31:34
Yes, I need to change the name of the flags to mak
|
| } else if (fun->AsProperty() != NULL) { |
| // Call to an object property. |
| Property* prop = fun->AsProperty(); |
| @@ -2284,7 +2300,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
| { PreservePositionScope scope(masm()->positions_recorder()); |
| VisitForStackValue(prop->obj()); |
| } |
| - EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); |
| + EmitKeyedCallWithIC(expr, prop->key()); |
| } |
| } |
| } else { |
| @@ -3630,9 +3646,10 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| // Call the JS runtime function via a call IC. |
| __ Set(ecx, Immediate(expr->name())); |
| InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| + RelocInfo::Mode mode = RelocInfo::CODE_TARGET; |
| Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize( |
| - arg_count, in_loop); |
| - EmitCallIC(ic, RelocInfo::CODE_TARGET, expr->id()); |
| + arg_count, in_loop, mode); |
| + EmitCallIC(ic, mode, expr->id()); |
| // Restore context register. |
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| } else { |