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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 7039036: Fix calls of strict mode function with an implicit receiver. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 years, 7 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/builtins-x64.cc ('k') | src/x64/full-codegen-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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 2940
2941 2941
2942 void StackCheckStub::Generate(MacroAssembler* masm) { 2942 void StackCheckStub::Generate(MacroAssembler* masm) {
2943 __ TailCallRuntime(Runtime::kStackGuard, 0, 1); 2943 __ TailCallRuntime(Runtime::kStackGuard, 0, 1);
2944 } 2944 }
2945 2945
2946 2946
2947 void CallFunctionStub::Generate(MacroAssembler* masm) { 2947 void CallFunctionStub::Generate(MacroAssembler* masm) {
2948 Label slow; 2948 Label slow;
2949 2949
2950 // If the receiver might be a value (string, number or boolean) check for this 2950 // The receiver might implicitly be the global object. This is
2951 // and box it if it is. 2951 // indicated by passing the hole as the receiver to the call
2952 if (ReceiverMightBeValue()) { 2952 // function stub.
2953 if (ReceiverMightBeImplicit()) {
2954 Label call;
2953 // Get the receiver from the stack. 2955 // Get the receiver from the stack.
2954 // +1 ~ return address 2956 // +1 ~ return address
2955 Label receiver_is_value, receiver_is_js_object;
2956 __ movq(rax, Operand(rsp, (argc_ + 1) * kPointerSize)); 2957 __ movq(rax, Operand(rsp, (argc_ + 1) * kPointerSize));
2957 2958 // Call as function is indicated with the hole.
2958 // Check if receiver is a smi (which is a number value). 2959 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2959 __ JumpIfSmi(rax, &receiver_is_value); 2960 __ j(not_equal, &call, Label::kNear);
2960 2961 // Patch the receiver on the stack with the global receiver object.
2961 // Check if the receiver is a valid JS object. 2962 __ movq(rbx, GlobalObjectOperand());
2962 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdi); 2963 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
2963 __ j(above_equal, &receiver_is_js_object); 2964 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rbx);
2964 2965 __ bind(&call);
2965 // Call the runtime to box the value.
2966 __ bind(&receiver_is_value);
2967 __ EnterInternalFrame();
2968 __ push(rax);
2969 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
2970 __ LeaveInternalFrame();
2971 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rax);
2972
2973 __ bind(&receiver_is_js_object);
2974 } 2966 }
2975 2967
2976 // Get the function to call from the stack. 2968 // Get the function to call from the stack.
2977 // +2 ~ receiver, return address 2969 // +2 ~ receiver, return address
2978 __ movq(rdi, Operand(rsp, (argc_ + 2) * kPointerSize)); 2970 __ movq(rdi, Operand(rsp, (argc_ + 2) * kPointerSize));
2979 2971
2980 // Check that the function really is a JavaScript function. 2972 // Check that the function really is a JavaScript function.
2981 __ JumpIfSmi(rdi, &slow); 2973 __ JumpIfSmi(rdi, &slow);
2982 // Goto slow case if we do not have a function. 2974 // Goto slow case if we do not have a function.
2983 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2975 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2984 __ j(not_equal, &slow); 2976 __ j(not_equal, &slow);
2985 2977
2986 // Fast-case: Just invoke the function. 2978 // Fast-case: Just invoke the function.
2987 ParameterCount actual(argc_); 2979 ParameterCount actual(argc_);
2988 __ InvokeFunction(rdi, actual, JUMP_FUNCTION); 2980
2981 if (ReceiverMightBeImplicit()) {
2982 Label call_as_function;
2983 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2984 __ j(equal, &call_as_function);
2985 __ InvokeFunction(rdi, actual, JUMP_FUNCTION);
2986 __ bind(&call_as_function);
2987 }
2988 __ InvokeFunction(rdi,
2989 actual,
2990 JUMP_FUNCTION,
2991 NullCallWrapper(),
2992 CALL_AS_FUNCTION);
2989 2993
2990 // Slow-case: Non-function called. 2994 // Slow-case: Non-function called.
2991 __ bind(&slow); 2995 __ bind(&slow);
2992 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead 2996 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead
2993 // of the original receiver from the call site). 2997 // of the original receiver from the call site).
2994 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rdi); 2998 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rdi);
2995 __ Set(rax, argc_); 2999 __ Set(rax, argc_);
2996 __ Set(rbx, 0); 3000 __ Set(rbx, 0);
2997 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); 3001 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION);
2998 Handle<Code> adaptor = 3002 Handle<Code> adaptor =
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5119 __ Drop(1); 5123 __ Drop(1);
5120 __ ret(2 * kPointerSize); 5124 __ ret(2 * kPointerSize);
5121 } 5125 }
5122 5126
5123 5127
5124 #undef __ 5128 #undef __
5125 5129
5126 } } // namespace v8::internal 5130 } } // namespace v8::internal
5127 5131
5128 #endif // V8_TARGET_ARCH_X64 5132 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698