Index: src/arm/full-codegen-arm.cc |
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc |
index 8ca06b8a52bfa8554759804e55f691621782600c..e1f82304e0bc1704ef056a5bd619f49f41ddf863 100644 |
--- a/src/arm/full-codegen-arm.cc |
+++ b/src/arm/full-codegen-arm.cc |
@@ -139,6 +139,20 @@ void FullCodeGenerator::Generate(CompilationInfo* info) { |
} |
#endif |
+ // Strict mode functions need to replace the receiver with undefined |
+ // when called as functions (without an explicit receiver |
+ // object). r5 is zero for method calls and non-zero for function |
+ // calls. |
+ if (info->is_strict_mode()) { |
+ Label ok; |
+ __ cmp(r5, Operand(0)); |
+ __ b(eq, &ok); |
+ int receiver_offset = scope()->num_parameters() * kPointerSize; |
+ __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
+ __ str(r2, MemOperand(sp, receiver_offset)); |
+ __ bind(&ok); |
+ } |
+ |
int locals_count = scope()->num_stack_slots(); |
__ Push(lr, fp, cp, r1); |
@@ -2093,7 +2107,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, |
// Call the IC initialization code. |
InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
Handle<Code> ic = |
- isolate()->stub_cache()->ComputeCallInitialize(arg_count, in_loop); |
+ isolate()->stub_cache()->ComputeCallInitialize(arg_count, in_loop, mode); |
EmitCallIC(ic, mode, expr->id()); |
RecordJSReturnSite(expr); |
// Restore context register. |
@@ -2103,8 +2117,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, |
void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
- Expression* key, |
- RelocInfo::Mode mode) { |
+ Expression* key) { |
// Load the key. |
VisitForAccumulatorValue(key); |
@@ -2129,7 +2142,7 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
Handle<Code> ic = |
isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count, in_loop); |
__ ldr(r2, MemOperand(sp, (arg_count + 1) * kPointerSize)); // Key. |
- EmitCallIC(ic, mode, expr->id()); |
+ EmitCallIC(ic, RelocInfo::CODE_TARGET, expr->id()); |
RecordJSReturnSite(expr); |
// Restore context register. |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
@@ -2245,7 +2258,7 @@ 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, RECEIVER_MIGHT_BE_IMPLICIT); |
__ CallStub(&stub); |
RecordJSReturnSite(expr); |
// Restore context register. |
@@ -2295,9 +2308,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_IMPLICIT); |
} else if (fun->AsProperty() != NULL) { |
// Call to an object property. |
Property* prop = fun->AsProperty(); |
@@ -2338,7 +2352,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 { |
@@ -3647,9 +3661,12 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
if (expr->is_jsruntime()) { |
// Call the JS runtime function. |
__ mov(r2, Operand(expr->name())); |
+ RelocInfo::Mode mode = RelocInfo::CODE_TARGET; |
Handle<Code> ic = |
- isolate()->stub_cache()->ComputeCallInitialize(arg_count, NOT_IN_LOOP); |
- EmitCallIC(ic, RelocInfo::CODE_TARGET, expr->id()); |
+ isolate()->stub_cache()->ComputeCallInitialize(arg_count, |
+ NOT_IN_LOOP, |
+ mode); |
+ EmitCallIC(ic, mode, expr->id()); |
// Restore context register. |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
} else { |