builtins-interpreter.cc revision f3b273f5e6ffd2f6ba1c18a27a17db41dfb113c3
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
8namespace v8 {
9namespace internal {
10
11Handle<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
31void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) {
32  return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kDisallow,
33                                                 CallableType::kAny);
34}
35
36void Builtins::Generate_InterpreterPushArgsAndCallFunction(
37    MacroAssembler* masm) {
38  return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kDisallow,
39                                                 CallableType::kJSFunction);
40}
41
42void Builtins::Generate_InterpreterPushArgsAndTailCall(MacroAssembler* masm) {
43  return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kAllow,
44                                                 CallableType::kAny);
45}
46
47void Builtins::Generate_InterpreterPushArgsAndTailCallFunction(
48    MacroAssembler* masm) {
49  return Generate_InterpreterPushArgsAndCallImpl(masm, TailCallMode::kAllow,
50                                                 CallableType::kJSFunction);
51}
52
53Handle<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
65void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
66  return Generate_InterpreterPushArgsAndConstructImpl(masm, CallableType::kAny);
67}
68
69void Builtins::Generate_InterpreterPushArgsAndConstructFunction(
70    MacroAssembler* masm) {
71  return Generate_InterpreterPushArgsAndConstructImpl(
72      masm, CallableType::kJSFunction);
73}
74
75}  // namespace internal
76}  // namespace v8
77