• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-utils.h"
6 #include "src/builtins/builtins.h"
7 #include "src/objects-inl.h"
8 
9 namespace v8 {
10 namespace internal {
11 
InterpreterPushArgsAndCall(TailCallMode tail_call_mode,InterpreterPushArgsMode mode)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 
Generate_InterpreterPushArgsAndCall(MacroAssembler * masm)35 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) {
36   return Generate_InterpreterPushArgsAndCallImpl(
37       masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kOther);
38 }
39 
Generate_InterpreterPushArgsAndCallFunction(MacroAssembler * masm)40 void Builtins::Generate_InterpreterPushArgsAndCallFunction(
41     MacroAssembler* masm) {
42   return Generate_InterpreterPushArgsAndCallImpl(
43       masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kJSFunction);
44 }
45 
Generate_InterpreterPushArgsAndCallWithFinalSpread(MacroAssembler * masm)46 void Builtins::Generate_InterpreterPushArgsAndCallWithFinalSpread(
47     MacroAssembler* masm) {
48   return Generate_InterpreterPushArgsAndCallImpl(
49       masm, TailCallMode::kDisallow, InterpreterPushArgsMode::kWithFinalSpread);
50 }
51 
Generate_InterpreterPushArgsAndTailCall(MacroAssembler * masm)52 void Builtins::Generate_InterpreterPushArgsAndTailCall(MacroAssembler* masm) {
53   return Generate_InterpreterPushArgsAndCallImpl(
54       masm, TailCallMode::kAllow, InterpreterPushArgsMode::kOther);
55 }
56 
Generate_InterpreterPushArgsAndTailCallFunction(MacroAssembler * masm)57 void Builtins::Generate_InterpreterPushArgsAndTailCallFunction(
58     MacroAssembler* masm) {
59   return Generate_InterpreterPushArgsAndCallImpl(
60       masm, TailCallMode::kAllow, InterpreterPushArgsMode::kJSFunction);
61 }
62 
InterpreterPushArgsAndConstruct(InterpreterPushArgsMode mode)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 
Generate_InterpreterPushArgsAndConstruct(MacroAssembler * masm)77 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
78   return Generate_InterpreterPushArgsAndConstructImpl(
79       masm, InterpreterPushArgsMode::kOther);
80 }
81 
Generate_InterpreterPushArgsAndConstructWithFinalSpread(MacroAssembler * masm)82 void Builtins::Generate_InterpreterPushArgsAndConstructWithFinalSpread(
83     MacroAssembler* masm) {
84   return Generate_InterpreterPushArgsAndConstructImpl(
85       masm, InterpreterPushArgsMode::kWithFinalSpread);
86 }
87 
Generate_InterpreterPushArgsAndConstructFunction(MacroAssembler * masm)88 void Builtins::Generate_InterpreterPushArgsAndConstructFunction(
89     MacroAssembler* masm) {
90   return Generate_InterpreterPushArgsAndConstructImpl(
91       masm, InterpreterPushArgsMode::kJSFunction);
92 }
93 
94 }  // namespace internal
95 }  // namespace v8
96