1 // Copyright 2011 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 #ifndef V8_X64_CODEGEN_X64_H_
6 #define V8_X64_CODEGEN_X64_H_
7 
8 #include "src/ast.h"
9 #include "src/macro-assembler.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 
15 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
16 
17 
18 class StringCharLoadGenerator : public AllStatic {
19  public:
20   // Generates the code for handling different string types and loading the
21   // indexed character into |result|.  We expect |index| as untagged input and
22   // |result| as untagged output.
23   static void Generate(MacroAssembler* masm,
24                        Register string,
25                        Register index,
26                        Register result,
27                        Label* call_runtime);
28 
29  private:
30   DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator);
31 };
32 
33 
34 class MathExpGenerator : public AllStatic {
35  public:
36   static void EmitMathExp(MacroAssembler* masm,
37                           XMMRegister input,
38                           XMMRegister result,
39                           XMMRegister double_scratch,
40                           Register temp1,
41                           Register temp2);
42 
43  private:
44   DISALLOW_COPY_AND_ASSIGN(MathExpGenerator);
45 };
46 
47 
48 enum StackArgumentsAccessorReceiverMode {
49   ARGUMENTS_CONTAIN_RECEIVER,
50   ARGUMENTS_DONT_CONTAIN_RECEIVER
51 };
52 
53 
54 class StackArgumentsAccessor BASE_EMBEDDED {
55  public:
56   StackArgumentsAccessor(
57       Register base_reg,
58       int argument_count_immediate,
59       StackArgumentsAccessorReceiverMode receiver_mode =
60           ARGUMENTS_CONTAIN_RECEIVER,
61       int extra_displacement_to_last_argument = 0)
base_reg_(base_reg)62       : base_reg_(base_reg),
63         argument_count_reg_(no_reg),
64         argument_count_immediate_(argument_count_immediate),
65         receiver_mode_(receiver_mode),
66         extra_displacement_to_last_argument_(
67             extra_displacement_to_last_argument) { }
68 
69   StackArgumentsAccessor(
70       Register base_reg,
71       Register argument_count_reg,
72       StackArgumentsAccessorReceiverMode receiver_mode =
73           ARGUMENTS_CONTAIN_RECEIVER,
74       int extra_displacement_to_last_argument = 0)
base_reg_(base_reg)75       : base_reg_(base_reg),
76         argument_count_reg_(argument_count_reg),
77         argument_count_immediate_(0),
78         receiver_mode_(receiver_mode),
79         extra_displacement_to_last_argument_(
80             extra_displacement_to_last_argument) { }
81 
82   StackArgumentsAccessor(
83       Register base_reg,
84       const ParameterCount& parameter_count,
85       StackArgumentsAccessorReceiverMode receiver_mode =
86           ARGUMENTS_CONTAIN_RECEIVER,
87       int extra_displacement_to_last_argument = 0)
base_reg_(base_reg)88       : base_reg_(base_reg),
89         argument_count_reg_(parameter_count.is_reg() ?
90                             parameter_count.reg() : no_reg),
91         argument_count_immediate_(parameter_count.is_immediate() ?
92                                   parameter_count.immediate() : 0),
93         receiver_mode_(receiver_mode),
94         extra_displacement_to_last_argument_(
95             extra_displacement_to_last_argument) { }
96 
97   Operand GetArgumentOperand(int index);
GetReceiverOperand()98   Operand GetReceiverOperand() {
99     DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER);
100     return GetArgumentOperand(0);
101   }
102 
103  private:
104   const Register base_reg_;
105   const Register argument_count_reg_;
106   const int argument_count_immediate_;
107   const StackArgumentsAccessorReceiverMode receiver_mode_;
108   const int extra_displacement_to_last_argument_;
109 
110   DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor);
111 };
112 
113 
114 } }  // namespace v8::internal
115 
116 #endif  // V8_X64_CODEGEN_X64_H_
117