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