Chromium Code Reviews| Index: src/arm/full-codegen-arm.cc |
| diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc |
| index 2b7cdef871627e2a2441f48b6aab0877948c79aa..0f5696897a2191dad53e315fa4e50d8078d025d1 100644 |
| --- a/src/arm/full-codegen-arm.cc |
| +++ b/src/arm/full-codegen-arm.cc |
| @@ -133,6 +133,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). ecx is zero for method calls and non-zero for function |
|
Kevin Millikin (Chromium)
2011/05/24 13:21:36
ecx ==> r5.
Mads Ager (chromium)
2011/05/24 13:57:53
Done.
|
| + // 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); |
| @@ -2095,7 +2109,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); |
| unsigned ast_id = |
| (mode == RelocInfo::CODE_TARGET_WITH_ID) ? expr->id() : kNoASTId; |
| EmitCallIC(ic, mode, ast_id); |
| @@ -2107,8 +2121,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, |
| void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
| - Expression* key, |
| - RelocInfo::Mode mode) { |
| + Expression* key) { |
| // Load the key. |
| VisitForAccumulatorValue(key); |
| @@ -2133,7 +2146,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)); |
| @@ -2249,7 +2262,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. |
| @@ -2299,9 +2312,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(); |
| @@ -2342,7 +2356,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
| { PreservePositionScope scope(masm()->positions_recorder()); |
| VisitForStackValue(prop->obj()); |
| } |
| - EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET_WITH_ID); |
| + EmitKeyedCallWithIC(expr, prop->key()); |
| } |
| } |
| } else { |
| @@ -3651,9 +3665,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; |
|
Mads Ager (chromium)
2011/05/24 13:04:14
Using CODE_TARGET here instead of CODE_TARGET_WITH
|
| Handle<Code> ic = |
| - isolate()->stub_cache()->ComputeCallInitialize(arg_count, NOT_IN_LOOP); |
| - EmitCallIC(ic, RelocInfo::CODE_TARGET_WITH_ID, 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 { |