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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 2074063002: [builtins] Always pass target and new target to C++ builtins (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/external-reference-table.cc ('k') | src/mips/builtins-mips.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
11 #include "src/ia32/frames-ia32.h" 11 #include "src/ia32/frames-ia32.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 16
17 #define __ ACCESS_MASM(masm) 17 #define __ ACCESS_MASM(masm)
18 18
19 19 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
20 void Builtins::Generate_Adaptor(MacroAssembler* masm,
21 CFunctionId id,
22 BuiltinExtraArguments extra_args) {
23 // ----------- S t a t e ------------- 20 // ----------- S t a t e -------------
24 // -- eax : number of arguments excluding receiver 21 // -- eax : number of arguments excluding receiver
25 // -- edi : target 22 // -- edi : target
26 // -- edx : new.target 23 // -- edx : new.target
27 // -- esp[0] : return address 24 // -- esp[0] : return address
28 // -- esp[4] : last argument 25 // -- esp[4] : last argument
29 // -- ... 26 // -- ...
30 // -- esp[4 * argc] : first argument 27 // -- esp[4 * argc] : first argument
31 // -- esp[4 * (argc +1)] : receiver 28 // -- esp[4 * (argc +1)] : receiver
32 // ----------------------------------- 29 // -----------------------------------
33 __ AssertFunction(edi); 30 __ AssertFunction(edi);
34 31
35 // Make sure we operate in the context of the called function (for example 32 // Make sure we operate in the context of the called function (for example
36 // ConstructStubs implemented in C++ will be run in the context of the caller 33 // ConstructStubs implemented in C++ will be run in the context of the caller
37 // instead of the callee, due to the way that [[Construct]] is defined for 34 // instead of the callee, due to the way that [[Construct]] is defined for
38 // ordinary functions). 35 // ordinary functions).
39 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 36 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
40 37
41 // Insert extra arguments. 38 // Insert extra arguments.
42 int num_extra_args = 0; 39 const int num_extra_args = 2;
43 if (extra_args != BuiltinExtraArguments::kNone) { 40 __ PopReturnAddressTo(ecx);
44 __ PopReturnAddressTo(ecx); 41 __ Push(edi);
45 if (extra_args & BuiltinExtraArguments::kTarget) { 42 __ Push(edx);
46 ++num_extra_args; 43 __ PushReturnAddressFrom(ecx);
47 __ Push(edi);
48 }
49 if (extra_args & BuiltinExtraArguments::kNewTarget) {
50 ++num_extra_args;
51 __ Push(edx);
52 }
53 __ PushReturnAddressFrom(ecx);
54 }
55 44
56 // JumpToExternalReference expects eax to contain the number of arguments 45 // JumpToExternalReference expects eax to contain the number of arguments
57 // including the receiver and the extra arguments. 46 // including the receiver and the extra arguments.
58 __ add(eax, Immediate(num_extra_args + 1)); 47 __ add(eax, Immediate(num_extra_args + 1));
59 48
60 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate()));
61 } 50 }
62 51
63 static void GenerateTailCallToReturnedCode(MacroAssembler* masm, 52 static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
64 Runtime::FunctionId function_id) { 53 Runtime::FunctionId function_id) {
(...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 // And "return" to the OSR entry point of the function. 2968 // And "return" to the OSR entry point of the function.
2980 __ ret(0); 2969 __ ret(0);
2981 } 2970 }
2982 2971
2983 2972
2984 #undef __ 2973 #undef __
2985 } // namespace internal 2974 } // namespace internal
2986 } // namespace v8 2975 } // namespace v8
2987 2976
2988 #endif // V8_TARGET_ARCH_IA32 2977 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/external-reference-table.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698