OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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 #include "src/builtins/builtins-utils.h" | |
6 #include "src/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
7 #include "src/objects-inl.h" | 6 #include "src/globals.h" |
| 7 #include "src/macro-assembler.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 Handle<Code> Builtins::InterpreterPushArgsAndCall( | |
13 TailCallMode tail_call_mode, InterpreterPushArgsMode mode) { | |
14 switch (mode) { | |
15 case InterpreterPushArgsMode::kJSFunction: | |
16 if (tail_call_mode == TailCallMode::kDisallow) { | |
17 return InterpreterPushArgsAndCallFunction(); | |
18 } else { | |
19 return InterpreterPushArgsAndTailCallFunction(); | |
20 } | |
21 case InterpreterPushArgsMode::kWithFinalSpread: | |
22 CHECK(tail_call_mode == TailCallMode::kDisallow); | |
23 return InterpreterPushArgsAndCallWithFinalSpread(); | |
24 case InterpreterPushArgsMode::kOther: | |
25 if (tail_call_mode == TailCallMode::kDisallow) { | |
26 return InterpreterPushArgsAndCall(); | |
27 } else { | |
28 return InterpreterPushArgsAndTailCall(); | |
29 } | |
30 } | |
31 UNREACHABLE(); | |
32 return Handle<Code>::null(); | |
33 } | |
34 | |
35 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { | 12 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
36 return Generate_InterpreterPushArgsAndCallImpl( | 13 return Generate_InterpreterPushArgsAndCallImpl( |
37 masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kOther); | 14 masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kOther); |
38 } | 15 } |
39 | 16 |
40 void Builtins::Generate_InterpreterPushArgsAndCallFunction( | 17 void Builtins::Generate_InterpreterPushArgsAndCallFunction( |
41 MacroAssembler* masm) { | 18 MacroAssembler* masm) { |
42 return Generate_InterpreterPushArgsAndCallImpl( | 19 return Generate_InterpreterPushArgsAndCallImpl( |
43 masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kJSFunction); | 20 masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kJSFunction); |
44 } | 21 } |
45 | 22 |
46 void Builtins::Generate_InterpreterPushArgsAndCallWithFinalSpread( | 23 void Builtins::Generate_InterpreterPushArgsAndCallWithFinalSpread( |
47 MacroAssembler* masm) { | 24 MacroAssembler* masm) { |
48 return Generate_InterpreterPushArgsAndCallImpl( | 25 return Generate_InterpreterPushArgsAndCallImpl( |
49 masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kWithFinalSpread); | 26 masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kWithFinalSpread); |
50 } | 27 } |
51 | 28 |
52 void Builtins::Generate_InterpreterPushArgsAndTailCall(MacroAssembler* masm) { | 29 void Builtins::Generate_InterpreterPushArgsAndTailCall(MacroAssembler* masm) { |
53 return Generate_InterpreterPushArgsAndCallImpl( | 30 return Generate_InterpreterPushArgsAndCallImpl( |
54 masm, TailCallMode::kAllow, InterpreterPushArgsMode::kOther); | 31 masm, TailCallMode::kAllow, InterpreterPushArgsMode::kOther); |
55 } | 32 } |
56 | 33 |
57 void Builtins::Generate_InterpreterPushArgsAndTailCallFunction( | 34 void Builtins::Generate_InterpreterPushArgsAndTailCallFunction( |
58 MacroAssembler* masm) { | 35 MacroAssembler* masm) { |
59 return Generate_InterpreterPushArgsAndCallImpl( | 36 return Generate_InterpreterPushArgsAndCallImpl( |
60 masm, TailCallMode::kAllow, InterpreterPushArgsMode::kJSFunction); | 37 masm, TailCallMode::kAllow, InterpreterPushArgsMode::kJSFunction); |
61 } | 38 } |
62 | 39 |
63 Handle<Code> Builtins::InterpreterPushArgsAndConstruct( | |
64 InterpreterPushArgsMode mode) { | |
65 switch (mode) { | |
66 case InterpreterPushArgsMode::kJSFunction: | |
67 return InterpreterPushArgsAndConstructFunction(); | |
68 case InterpreterPushArgsMode::kWithFinalSpread: | |
69 return InterpreterPushArgsAndConstructWithFinalSpread(); | |
70 case InterpreterPushArgsMode::kOther: | |
71 return InterpreterPushArgsAndConstruct(); | |
72 } | |
73 UNREACHABLE(); | |
74 return Handle<Code>::null(); | |
75 } | |
76 | |
77 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 40 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
78 return Generate_InterpreterPushArgsAndConstructImpl( | 41 return Generate_InterpreterPushArgsAndConstructImpl( |
79 masm, InterpreterPushArgsMode::kOther); | 42 masm, InterpreterPushArgsMode::kOther); |
80 } | 43 } |
81 | 44 |
82 void Builtins::Generate_InterpreterPushArgsAndConstructWithFinalSpread( | 45 void Builtins::Generate_InterpreterPushArgsAndConstructWithFinalSpread( |
83 MacroAssembler* masm) { | 46 MacroAssembler* masm) { |
84 return Generate_InterpreterPushArgsAndConstructImpl( | 47 return Generate_InterpreterPushArgsAndConstructImpl( |
85 masm, InterpreterPushArgsMode::kWithFinalSpread); | 48 masm, InterpreterPushArgsMode::kWithFinalSpread); |
86 } | 49 } |
87 | 50 |
88 void Builtins::Generate_InterpreterPushArgsAndConstructFunction( | 51 void Builtins::Generate_InterpreterPushArgsAndConstructFunction( |
89 MacroAssembler* masm) { | 52 MacroAssembler* masm) { |
90 return Generate_InterpreterPushArgsAndConstructImpl( | 53 return Generate_InterpreterPushArgsAndConstructImpl( |
91 masm, InterpreterPushArgsMode::kJSFunction); | 54 masm, InterpreterPushArgsMode::kJSFunction); |
92 } | 55 } |
93 | 56 |
94 } // namespace internal | 57 } // namespace internal |
95 } // namespace v8 | 58 } // namespace v8 |
OLD | NEW |