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

Side by Side Diff: src/x64/full-codegen-x64.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/x64/code-stubs-x64.cc ('k') | src/x64/ic-x64.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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 ProfileEntryHookStub::MaybeCallEntryHook(masm_); 126 ProfileEntryHookStub::MaybeCallEntryHook(masm_);
127 127
128 #ifdef DEBUG 128 #ifdef DEBUG
129 if (strlen(FLAG_stop_at) > 0 && 129 if (strlen(FLAG_stop_at) > 0 &&
130 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { 130 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) {
131 __ int3(); 131 __ int3();
132 } 132 }
133 #endif 133 #endif
134 134
135 // Strict mode functions and builtins need to replace the receiver 135 // Classic mode functions and builtins need to replace the receiver with the
136 // with undefined when called as functions (without an explicit 136 // global proxy when called as functions (without an explicit receiver
137 // receiver object). rcx is zero for method calls and non-zero for 137 // object).
138 // function calls. 138 if (info->is_classic_mode() && !info->is_native()) {
139 if (!info->is_classic_mode() || info->is_native()) {
140 Label ok; 139 Label ok;
141 __ testq(rcx, rcx); 140 __ testq(rcx, rcx);
142 __ j(zero, &ok, Label::kNear); 141 __ j(zero, &ok, Label::kNear);
142
143 // +1 for return address.
143 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); 144 StackArgumentsAccessor args(rsp, info->scope()->num_parameters());
144 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); 145 __ movq(rcx, args.GetReceiverOperand());
145 __ movq(args.GetReceiverOperand(), kScratchRegister); 146
147 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex);
148 __ j(not_equal, &ok, Label::kNear);
149
150 __ movq(rcx, GlobalObjectOperand());
151 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset));
152
153 __ movq(args.GetReceiverOperand(), rcx);
154
146 __ bind(&ok); 155 __ bind(&ok);
147 } 156 }
148 157
149 // Open a frame scope to indicate that there is a frame on the stack. The 158 // Open a frame scope to indicate that there is a frame on the stack. The
150 // MANUAL indicates that the scope shouldn't actually generate code to set up 159 // MANUAL indicates that the scope shouldn't actually generate code to set up
151 // the frame (that is done below). 160 // the frame (that is done below).
152 FrameScope frame_scope(masm_, StackFrame::MANUAL); 161 FrameScope frame_scope(masm_, StackFrame::MANUAL);
153 162
154 info->set_prologue_offset(masm_->pc_offset()); 163 info->set_prologue_offset(masm_->pc_offset());
155 __ Prologue(BUILD_FUNCTION_FRAME); 164 __ Prologue(BUILD_FUNCTION_FRAME);
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 __ push(Operand(rsp, (arg_count + 1) * kPointerSize)); 2670 __ push(Operand(rsp, (arg_count + 1) * kPointerSize));
2662 EmitResolvePossiblyDirectEval(arg_count); 2671 EmitResolvePossiblyDirectEval(arg_count);
2663 2672
2664 // The runtime call returns a pair of values in rax (function) and 2673 // The runtime call returns a pair of values in rax (function) and
2665 // rdx (receiver). Touch up the stack with the right values. 2674 // rdx (receiver). Touch up the stack with the right values.
2666 __ movq(Operand(rsp, (arg_count + 0) * kPointerSize), rdx); 2675 __ movq(Operand(rsp, (arg_count + 0) * kPointerSize), rdx);
2667 __ movq(Operand(rsp, (arg_count + 1) * kPointerSize), rax); 2676 __ movq(Operand(rsp, (arg_count + 1) * kPointerSize), rax);
2668 } 2677 }
2669 // Record source position for debugger. 2678 // Record source position for debugger.
2670 SetSourcePosition(expr->position()); 2679 SetSourcePosition(expr->position());
2671 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); 2680 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
2672 __ movq(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); 2681 __ movq(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
2673 __ CallStub(&stub); 2682 __ CallStub(&stub);
2674 RecordJSReturnSite(expr); 2683 RecordJSReturnSite(expr);
2675 // Restore context register. 2684 // Restore context register.
2676 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 2685 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2677 context()->DropAndPlug(1, rax); 2686 context()->DropAndPlug(1, rax);
2678 } else if (proxy != NULL && proxy->var()->IsUnallocated()) { 2687 } else if (proxy != NULL && proxy->var()->IsUnallocated()) {
2679 // Call to a global variable. Push global object as receiver for the 2688 // Call to a global variable. Push global object as receiver for the
2680 // call IC lookup. 2689 // call IC lookup.
2681 __ push(GlobalObjectOperand()); 2690 __ push(GlobalObjectOperand());
(...skipping 19 matching lines...) Expand all
2701 // If fast case code has been generated, emit code to push the function 2710 // If fast case code has been generated, emit code to push the function
2702 // and receiver and have the slow path jump around this code. 2711 // and receiver and have the slow path jump around this code.
2703 if (done.is_linked()) { 2712 if (done.is_linked()) {
2704 Label call; 2713 Label call;
2705 __ jmp(&call, Label::kNear); 2714 __ jmp(&call, Label::kNear);
2706 __ bind(&done); 2715 __ bind(&done);
2707 // Push function. 2716 // Push function.
2708 __ push(rax); 2717 __ push(rax);
2709 // The receiver is implicitly the global receiver. Indicate this by 2718 // The receiver is implicitly the global receiver. Indicate this by
2710 // passing the hole to the call function stub. 2719 // passing the hole to the call function stub.
2711 __ PushRoot(Heap::kTheHoleValueRootIndex); 2720 __ PushRoot(Heap::kUndefinedValueRootIndex);
2712 __ bind(&call); 2721 __ bind(&call);
2713 } 2722 }
2714 2723
2715 // The receiver is either the global receiver or an object found by 2724 // The receiver is either the global receiver or an object found by
2716 // LoadContextSlot. That object could be the hole if the receiver is 2725 // LoadContextSlot.
2717 // implicitly the global object. 2726 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
2718 EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT);
2719 } else if (property != NULL) { 2727 } else if (property != NULL) {
2720 { PreservePositionScope scope(masm()->positions_recorder()); 2728 { PreservePositionScope scope(masm()->positions_recorder());
2721 VisitForStackValue(property->obj()); 2729 VisitForStackValue(property->obj());
2722 } 2730 }
2723 if (property->key()->IsPropertyName()) { 2731 if (property->key()->IsPropertyName()) {
2724 EmitCallWithIC(expr, 2732 EmitCallWithIC(expr,
2725 property->key()->AsLiteral()->value(), 2733 property->key()->AsLiteral()->value(),
2726 NOT_CONTEXTUAL); 2734 NOT_CONTEXTUAL);
2727 } else { 2735 } else {
2728 EmitKeyedCallWithIC(expr, property->key()); 2736 EmitKeyedCallWithIC(expr, property->key());
2729 } 2737 }
2730 } else { 2738 } else {
2731 // Call to an arbitrary expression not handled specially above. 2739 // Call to an arbitrary expression not handled specially above.
2732 { PreservePositionScope scope(masm()->positions_recorder()); 2740 { PreservePositionScope scope(masm()->positions_recorder());
2733 VisitForStackValue(callee); 2741 VisitForStackValue(callee);
2734 } 2742 }
2735 // Push the hole as receiver. 2743 __ PushRoot(Heap::kUndefinedValueRootIndex);
2736 // It will be correctly replaced in the call stub.
2737 __ PushRoot(Heap::kTheHoleValueRootIndex);
2738 // Emit function call. 2744 // Emit function call.
2739 EmitCallWithStub(expr, RECEIVER_IS_IMPLICIT); 2745 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
2740 } 2746 }
2741 2747
2742 #ifdef DEBUG 2748 #ifdef DEBUG
2743 // RecordJSReturnSite should have been called. 2749 // RecordJSReturnSite should have been called.
2744 ASSERT(expr->return_is_recorded_); 2750 ASSERT(expr->return_is_recorded_);
2745 #endif 2751 #endif
2746 } 2752 }
2747 2753
2748 2754
2749 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 2755 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 Label runtime, done; 3661 Label runtime, done;
3656 // Check for non-function argument (including proxy). 3662 // Check for non-function argument (including proxy).
3657 __ JumpIfSmi(rax, &runtime); 3663 __ JumpIfSmi(rax, &runtime);
3658 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); 3664 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
3659 __ j(not_equal, &runtime); 3665 __ j(not_equal, &runtime);
3660 3666
3661 // InvokeFunction requires the function in rdi. Move it in there. 3667 // InvokeFunction requires the function in rdi. Move it in there.
3662 __ movq(rdi, result_register()); 3668 __ movq(rdi, result_register());
3663 ParameterCount count(arg_count); 3669 ParameterCount count(arg_count);
3664 __ InvokeFunction(rdi, count, CALL_FUNCTION, 3670 __ InvokeFunction(rdi, count, CALL_FUNCTION,
3665 NullCallWrapper(), CALL_AS_METHOD); 3671 NullCallWrapper(), CALL_AS_FUNCTION);
3666 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 3672 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3667 __ jmp(&done); 3673 __ jmp(&done);
3668 3674
3669 __ bind(&runtime); 3675 __ bind(&runtime);
3670 __ push(rax); 3676 __ push(rax);
3671 __ CallRuntime(Runtime::kCall, args->length()); 3677 __ CallRuntime(Runtime::kCall, args->length());
3672 __ bind(&done); 3678 __ bind(&done);
3673 3679
3674 context()->Plug(rax); 3680 context()->Plug(rax);
3675 } 3681 }
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4883 4889
4884 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4890 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4885 Assembler::target_address_at(call_target_address)); 4891 Assembler::target_address_at(call_target_address));
4886 return OSR_AFTER_STACK_CHECK; 4892 return OSR_AFTER_STACK_CHECK;
4887 } 4893 }
4888 4894
4889 4895
4890 } } // namespace v8::internal 4896 } } // namespace v8::internal
4891 4897
4892 #endif // V8_TARGET_ARCH_X64 4898 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698