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
3 // found in the LICENSE file.
4
5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h"
7
8 namespace v8 {
9 namespace internal {
10
InterpreterPushArgsAndCall(TailCallMode tail_call_mode,CallableType function_type)11 Handle<Code> Builtins::InterpreterPushArgsAndCall(TailCallMode tail_call_mode,
12 CallableType function_type) {
13 switch (tail_call_mode) {
14 case TailCallMode::kDisallow:
15 if (function_type == CallableType::kJSFunction) {
16 return InterpreterPushArgsAndCallFunction();
17 } else {
18 return InterpreterPushArgsAndCall();
19 }
20 case TailCallMode::kAllow:
21 if (function_type == CallableType::kJSFunction) {
22 return InterpreterPushArgsAndTailCallFunction();
23 } else {
24 return InterpreterPushArgsAndTailCall();
25 }
26 }
27 UNREACHABLE();
28 return Handle<Code>::null();
29 }
30
Generate_InterpreterPushArgsAndCall(MacroAssembler * masm)31 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) {
32 return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kDisallow,
33 CallableType::kAny);
34 }
35
Generate_InterpreterPushArgsAndCallFunction(MacroAssembler * masm)36 void Builtins::Generate_InterpreterPushArgsAndCallFunction(
37 MacroAssembler* masm) {
38 return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kDisallow,
39 CallableType::kJSFunction);
40 }
41
Generate_InterpreterPushArgsAndTailCall(MacroAssembler * masm)42 void Builtins::Generate_InterpreterPushArgsAndTailCall(MacroAssembler* masm) {
43 return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kAllow,
44 CallableType::kAny);
45 }
46
Generate_InterpreterPushArgsAndTailCallFunction(MacroAssembler * masm)47 void Builtins::Generate_InterpreterPushArgsAndTailCallFunction(
48 MacroAssembler* masm) {
49 return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kAllow,
50 CallableType::kJSFunction);
51 }
52
InterpreterPushArgsAndConstruct(CallableType function_type)53 Handle<Code> Builtins::InterpreterPushArgsAndConstruct(
54 CallableType function_type) {
55 switch (function_type) {
56 case CallableType::kJSFunction:
57 return InterpreterPushArgsAndConstructFunction();
58 case CallableType::kAny:
59 return InterpreterPushArgsAndConstruct();
60 }
61 UNREACHABLE();
62 return Handle<Code>::null();
63 }
64
Generate_InterpreterPushArgsAndConstruct(MacroAssembler * masm)65 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
66 return Generate_InterpreterPushArgsAndConstructImpl(masm, CallableType::kAny);
67 }
68
Generate_InterpreterPushArgsAndConstructFunction(MacroAssembler * masm)69 void Builtins::Generate_InterpreterPushArgsAndConstructFunction(
70 MacroAssembler* masm) {
71 return Generate_InterpreterPushArgsAndConstructImpl(
72 masm, CallableType::kJSFunction);
73 }
74
75 } // namespace internal
76 } // namespace v8
77