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

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: Port to x64 and arm. 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
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 2934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 2945
2946 2946
2947 void StackCheckStub::Generate(MacroAssembler* masm) { 2947 void StackCheckStub::Generate(MacroAssembler* masm) {
2948 __ TailCallRuntime(Runtime::kStackGuard, 0, 1); 2948 __ TailCallRuntime(Runtime::kStackGuard, 0, 1);
2949 } 2949 }
2950 2950
2951 2951
2952 void CallFunctionStub::Generate(MacroAssembler* masm) { 2952 void CallFunctionStub::Generate(MacroAssembler* masm) {
2953 Label slow; 2953 Label slow;
2954 2954
2955 // If the receiver might be a value (string, number or boolean) check for this 2955 // The receiver might implicitly be the global object. This is
2956 // and box it if it is. 2956 // indicated by passing the hole as the receiver to the call
2957 if (ReceiverMightBeValue()) { 2957 // function stub.
2958 if (ReceiverMightBeImplicit()) {
2959 Label call;
2958 // Get the receiver from the stack. 2960 // Get the receiver from the stack.
2959 // +1 ~ return address 2961 // +1 ~ return address
2960 Label receiver_is_value, receiver_is_js_object;
2961 __ movq(rax, Operand(rsp, (argc_ + 1) * kPointerSize)); 2962 __ movq(rax, Operand(rsp, (argc_ + 1) * kPointerSize));
2962 2963 // Call as function is indicated with the hole.
2963 // Check if receiver is a smi (which is a number value). 2964 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2964 __ JumpIfSmi(rax, &receiver_is_value); 2965 __ j(not_equal, &call, Label::kNear);
2965 2966 // Patch the receiver on the stack with the global receiver object.
2966 // Check if the receiver is a valid JS object. 2967 __ movq(rbx, GlobalObjectOperand());
2967 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdi); 2968 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
2968 __ j(above_equal, &receiver_is_js_object); 2969 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rbx);
2969 2970 __ bind(&call);
2970 // Call the runtime to box the value.
2971 __ bind(&receiver_is_value);
2972 __ EnterInternalFrame();
2973 __ push(rax);
2974 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
2975 __ LeaveInternalFrame();
2976 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rax);
2977
2978 __ bind(&receiver_is_js_object);
2979 } 2971 }
2980 2972
2981 // Get the function to call from the stack. 2973 // Get the function to call from the stack.
2982 // +2 ~ receiver, return address 2974 // +2 ~ receiver, return address
2983 __ movq(rdi, Operand(rsp, (argc_ + 2) * kPointerSize)); 2975 __ movq(rdi, Operand(rsp, (argc_ + 2) * kPointerSize));
2984 2976
2985 // Check that the function really is a JavaScript function. 2977 // Check that the function really is a JavaScript function.
2986 __ JumpIfSmi(rdi, &slow); 2978 __ JumpIfSmi(rdi, &slow);
2987 // Goto slow case if we do not have a function. 2979 // Goto slow case if we do not have a function.
2988 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2980 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2989 __ j(not_equal, &slow); 2981 __ j(not_equal, &slow);
2990 2982
2991 // Fast-case: Just invoke the function. 2983 // Fast-case: Just invoke the function.
2992 ParameterCount actual(argc_); 2984 ParameterCount actual(argc_);
2993 __ InvokeFunction(rdi, actual, JUMP_FUNCTION); 2985
2986 if (ReceiverMightBeImplicit()) {
2987 Label call_as_function;
2988 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2989 __ j(equal, &call_as_function);
2990 __ InvokeFunction(rdi, actual, JUMP_FUNCTION);
2991 __ bind(&call_as_function);
2992 }
2993 __ InvokeFunction(rdi,
2994 actual,
2995 JUMP_FUNCTION,
2996 NullCallWrapper(),
2997 CALL_AS_FUNCTION);
2994 2998
2995 // Slow-case: Non-function called. 2999 // Slow-case: Non-function called.
2996 __ bind(&slow); 3000 __ bind(&slow);
2997 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead 3001 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead
2998 // of the original receiver from the call site). 3002 // of the original receiver from the call site).
2999 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rdi); 3003 __ movq(Operand(rsp, (argc_ + 1) * kPointerSize), rdi);
3000 __ Set(rax, argc_); 3004 __ Set(rax, argc_);
3001 __ Set(rbx, 0); 3005 __ Set(rbx, 0);
3002 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); 3006 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION);
3003 Handle<Code> adaptor = 3007 Handle<Code> adaptor =
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5124 __ Drop(1); 5128 __ Drop(1);
5125 __ ret(2 * kPointerSize); 5129 __ ret(2 * kPointerSize);
5126 } 5130 }
5127 5131
5128 5132
5129 #undef __ 5133 #undef __
5130 5134
5131 } } // namespace v8::internal 5135 } } // namespace v8::internal
5132 5136
5133 #endif // V8_TARGET_ARCH_X64 5137 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698