Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 131663003: Make the strict-mode calling convention for contextual calls the default one. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix arm port Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 ProfileEntryHookStub::MaybeCallEntryHook(masm_); 127 ProfileEntryHookStub::MaybeCallEntryHook(masm_);
128 128
129 #ifdef DEBUG 129 #ifdef DEBUG
130 if (strlen(FLAG_stop_at) > 0 && 130 if (strlen(FLAG_stop_at) > 0 &&
131 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { 131 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) {
132 __ int3(); 132 __ int3();
133 } 133 }
134 #endif 134 #endif
135 135
136 // Strict mode functions and builtins need to replace the receiver 136 // Classic mode functions and builtins need to replace the receiver with the
137 // with undefined when called as functions (without an explicit 137 // global proxy when called as functions (without an explicit receiver
138 // receiver object). ecx is zero for method calls and non-zero for 138 // object).
139 // function calls. 139 if (info->is_classic_mode() && !info->is_native()) {
140 if (!info->is_classic_mode() || info->is_native()) {
141 Label ok; 140 Label ok;
142 __ test(ecx, ecx); 141 __ test(ecx, ecx);
143 __ j(zero, &ok, Label::kNear); 142 __ j(zero, &ok, Label::kNear);
143
144 // +1 for return address. 144 // +1 for return address.
145 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; 145 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize;
146 __ mov(ecx, Operand(esp, receiver_offset)); 146 __ mov(ecx, Operand(esp, receiver_offset));
147 __ JumpIfSmi(ecx, &ok); 147
148 __ CmpObjectType(ecx, JS_GLOBAL_PROXY_TYPE, ecx); 148 __ cmp(ecx, isolate()->factory()->undefined_value());
149 __ j(not_equal, &ok, Label::kNear); 149 __ j(not_equal, &ok, Label::kNear);
150 __ mov(Operand(esp, receiver_offset), 150
151 Immediate(isolate()->factory()->undefined_value())); 151 __ mov(ecx, GlobalObjectOperand());
152 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
153
154 __ mov(Operand(esp, receiver_offset), ecx);
155
152 __ bind(&ok); 156 __ bind(&ok);
153 } 157 }
154 158
155 // Open a frame scope to indicate that there is a frame on the stack. The 159 // Open a frame scope to indicate that there is a frame on the stack. The
156 // MANUAL indicates that the scope shouldn't actually generate code to set up 160 // MANUAL indicates that the scope shouldn't actually generate code to set up
157 // the frame (that is done below). 161 // the frame (that is done below).
158 FrameScope frame_scope(masm_, StackFrame::MANUAL); 162 FrameScope frame_scope(masm_, StackFrame::MANUAL);
159 163
160 info->set_prologue_offset(masm_->pc_offset()); 164 info->set_prologue_offset(masm_->pc_offset());
161 __ Prologue(BUILD_FUNCTION_FRAME); 165 __ Prologue(BUILD_FUNCTION_FRAME);
(...skipping 2519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); 2685 __ push(Operand(esp, (arg_count + 1) * kPointerSize));
2682 EmitResolvePossiblyDirectEval(arg_count); 2686 EmitResolvePossiblyDirectEval(arg_count);
2683 2687
2684 // The runtime call returns a pair of values in eax (function) and 2688 // The runtime call returns a pair of values in eax (function) and
2685 // edx (receiver). Touch up the stack with the right values. 2689 // edx (receiver). Touch up the stack with the right values.
2686 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx); 2690 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx);
2687 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); 2691 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax);
2688 } 2692 }
2689 // Record source position for debugger. 2693 // Record source position for debugger.
2690 SetSourcePosition(expr->position()); 2694 SetSourcePosition(expr->position());
2691 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); 2695 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
2692 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); 2696 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
2693 __ CallStub(&stub); 2697 __ CallStub(&stub);
2694 RecordJSReturnSite(expr); 2698 RecordJSReturnSite(expr);
2695 // Restore context register. 2699 // Restore context register.
2696 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2700 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2697 context()->DropAndPlug(1, eax); 2701 context()->DropAndPlug(1, eax);
2698 2702
2699 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { 2703 } else if (proxy != NULL && proxy->var()->IsUnallocated()) {
2700 // Push global object as receiver for the call IC. 2704 // Push global object as receiver for the call IC.
2701 __ push(GlobalObjectOperand()); 2705 __ push(GlobalObjectOperand());
(...skipping 18 matching lines...) Expand all
2720 // If fast case code has been generated, emit code to push the function 2724 // If fast case code has been generated, emit code to push the function
2721 // and receiver and have the slow path jump around this code. 2725 // and receiver and have the slow path jump around this code.
2722 if (done.is_linked()) { 2726 if (done.is_linked()) {
2723 Label call; 2727 Label call;
2724 __ jmp(&call, Label::kNear); 2728 __ jmp(&call, Label::kNear);
2725 __ bind(&done); 2729 __ bind(&done);
2726 // Push function. 2730 // Push function.
2727 __ push(eax); 2731 __ push(eax);
2728 // The receiver is implicitly the global receiver. Indicate this by 2732 // The receiver is implicitly the global receiver. Indicate this by
2729 // passing the hole to the call function stub. 2733 // passing the hole to the call function stub.
2730 __ push(Immediate(isolate()->factory()->the_hole_value())); 2734 __ push(Immediate(isolate()->factory()->undefined_value()));
2731 __ bind(&call); 2735 __ bind(&call);
2732 } 2736 }
2733 2737
2734 // The receiver is either the global receiver or an object found by 2738 // The receiver is either the global receiver or an object found by
2735 // LoadContextSlot. That object could be the hole if the receiver is 2739 // LoadContextSlot.
2736 // implicitly the global object. 2740 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
2737 EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT);
2738 2741
2739 } else if (property != NULL) { 2742 } else if (property != NULL) {
2740 { PreservePositionScope scope(masm()->positions_recorder()); 2743 { PreservePositionScope scope(masm()->positions_recorder());
2741 VisitForStackValue(property->obj()); 2744 VisitForStackValue(property->obj());
2742 } 2745 }
2743 if (property->key()->IsPropertyName()) { 2746 if (property->key()->IsPropertyName()) {
2744 EmitCallWithIC(expr, 2747 EmitCallWithIC(expr,
2745 property->key()->AsLiteral()->value(), 2748 property->key()->AsLiteral()->value(),
2746 NOT_CONTEXTUAL); 2749 NOT_CONTEXTUAL);
2747 } else { 2750 } else {
2748 EmitKeyedCallWithIC(expr, property->key()); 2751 EmitKeyedCallWithIC(expr, property->key());
2749 } 2752 }
2750 2753
2751 } else { 2754 } else {
2752 // Call to an arbitrary expression not handled specially above. 2755 // Call to an arbitrary expression not handled specially above.
2753 { PreservePositionScope scope(masm()->positions_recorder()); 2756 { PreservePositionScope scope(masm()->positions_recorder());
2754 VisitForStackValue(callee); 2757 VisitForStackValue(callee);
2755 } 2758 }
2756 // Push the hole as receiver. 2759 __ push(Immediate(isolate()->factory()->undefined_value()));
2757 // It will be correctly replaced in the call stub.
2758 __ push(Immediate(isolate()->factory()->the_hole_value()));
2759 // Emit function call. 2760 // Emit function call.
2760 EmitCallWithStub(expr, RECEIVER_IS_IMPLICIT); 2761 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
2761 } 2762 }
2762 2763
2763 #ifdef DEBUG 2764 #ifdef DEBUG
2764 // RecordJSReturnSite should have been called. 2765 // RecordJSReturnSite should have been called.
2765 ASSERT(expr->return_is_recorded_); 2766 ASSERT(expr->return_is_recorded_);
2766 #endif 2767 #endif
2767 } 2768 }
2768 2769
2769 2770
2770 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 2771 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
3686 Label runtime, done; 3687 Label runtime, done;
3687 // Check for non-function argument (including proxy). 3688 // Check for non-function argument (including proxy).
3688 __ JumpIfSmi(eax, &runtime); 3689 __ JumpIfSmi(eax, &runtime);
3689 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); 3690 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
3690 __ j(not_equal, &runtime); 3691 __ j(not_equal, &runtime);
3691 3692
3692 // InvokeFunction requires the function in edi. Move it in there. 3693 // InvokeFunction requires the function in edi. Move it in there.
3693 __ mov(edi, result_register()); 3694 __ mov(edi, result_register());
3694 ParameterCount count(arg_count); 3695 ParameterCount count(arg_count);
3695 __ InvokeFunction(edi, count, CALL_FUNCTION, 3696 __ InvokeFunction(edi, count, CALL_FUNCTION,
3696 NullCallWrapper(), CALL_AS_METHOD); 3697 NullCallWrapper(), CALL_AS_FUNCTION);
3697 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 3698 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3698 __ jmp(&done); 3699 __ jmp(&done);
3699 3700
3700 __ bind(&runtime); 3701 __ bind(&runtime);
3701 __ push(eax); 3702 __ push(eax);
3702 __ CallRuntime(Runtime::kCall, args->length()); 3703 __ CallRuntime(Runtime::kCall, args->length());
3703 __ bind(&done); 3704 __ bind(&done);
3704 3705
3705 context()->Plug(eax); 3706 context()->Plug(eax);
3706 } 3707 }
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
4889 4890
4890 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4891 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4891 Assembler::target_address_at(call_target_address)); 4892 Assembler::target_address_at(call_target_address));
4892 return OSR_AFTER_STACK_CHECK; 4893 return OSR_AFTER_STACK_CHECK;
4893 } 4894 }
4894 4895
4895 4896
4896 } } // namespace v8::internal 4897 } } // namespace v8::internal
4897 4898
4898 #endif // V8_TARGET_ARCH_IA32 4899 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698