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/globals.h"
8 #include "src/handles-inl.h"
9 #include "src/objects-inl.h"
10 
11 namespace v8 {
12 namespace internal {
13 
InterpreterPushArgsThenCall(ConvertReceiverMode receiver_mode,InterpreterPushArgsMode mode)14 Handle<Code> Builtins::InterpreterPushArgsThenCall(
15     ConvertReceiverMode receiver_mode, InterpreterPushArgsMode mode) {
16   switch (mode) {
17     case InterpreterPushArgsMode::kArrayFunction:
18       // There is no special-case handling of calls to Array. They will all go
19       // through the kOther case below.
20       UNREACHABLE();
21     case InterpreterPushArgsMode::kWithFinalSpread:
22       return builtin_handle(kInterpreterPushArgsThenCallWithFinalSpread);
23     case InterpreterPushArgsMode::kOther:
24       switch (receiver_mode) {
25         case ConvertReceiverMode::kNullOrUndefined:
26           return builtin_handle(kInterpreterPushUndefinedAndArgsThenCall);
27         case ConvertReceiverMode::kNotNullOrUndefined:
28         case ConvertReceiverMode::kAny:
29           return builtin_handle(kInterpreterPushArgsThenCall);
30       }
31   }
32   UNREACHABLE();
33 }
34 
InterpreterPushArgsThenConstruct(InterpreterPushArgsMode mode)35 Handle<Code> Builtins::InterpreterPushArgsThenConstruct(
36     InterpreterPushArgsMode mode) {
37   switch (mode) {
38     case InterpreterPushArgsMode::kArrayFunction:
39       return builtin_handle(kInterpreterPushArgsThenConstructArrayFunction);
40     case InterpreterPushArgsMode::kWithFinalSpread:
41       return builtin_handle(kInterpreterPushArgsThenConstructWithFinalSpread);
42     case InterpreterPushArgsMode::kOther:
43       return builtin_handle(kInterpreterPushArgsThenConstruct);
44   }
45   UNREACHABLE();
46 }
47 
48 }  // namespace internal
49 }  // namespace v8
50