V8 Project
codegen.h
Go to the documentation of this file.
1 // Copyright 2012 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_CODEGEN_H_
6 #define V8_CODEGEN_H_
7 
8 #include "src/code-stubs.h"
9 #include "src/runtime/runtime.h"
10 
11 // Include the declaration of the architecture defined class CodeGenerator.
12 // The contract to the shared code is that the the CodeGenerator is a subclass
13 // of Visitor and that the following methods are available publicly:
14 // MakeCode
15 // MakeCodePrologue
16 // MakeCodeEpilogue
17 // masm
18 // frame
19 // script
20 // has_valid_frame
21 // SetFrame
22 // DeleteFrame
23 // allocator
24 // AddDeferred
25 // in_spilled_code
26 // set_in_spilled_code
27 // RecordPositions
28 //
29 // These methods are either used privately by the shared code or implemented as
30 // shared code:
31 // CodeGenerator
32 // ~CodeGenerator
33 // Generate
34 // ComputeLazyCompile
35 // BuildFunctionInfo
36 // ProcessDeclarations
37 // DeclareGlobals
38 // CheckForInlineRuntimeCall
39 // AnalyzeCondition
40 // CodeForFunctionPosition
41 // CodeForReturnPosition
42 // CodeForStatementPosition
43 // CodeForDoWhileConditionPosition
44 // CodeForSourcePosition
45 
47 
48 #if V8_TARGET_ARCH_IA32
49 #include "src/ia32/codegen-ia32.h" // NOLINT
50 #elif V8_TARGET_ARCH_X64
51 #include "src/x64/codegen-x64.h" // NOLINT
52 #elif V8_TARGET_ARCH_ARM64
53 #include "src/arm64/codegen-arm64.h" // NOLINT
54 #elif V8_TARGET_ARCH_ARM
55 #include "src/arm/codegen-arm.h" // NOLINT
56 #elif V8_TARGET_ARCH_MIPS
57 #include "src/mips/codegen-mips.h" // NOLINT
58 #elif V8_TARGET_ARCH_MIPS64
59 #include "src/mips64/codegen-mips64.h" // NOLINT
60 #elif V8_TARGET_ARCH_X87
61 #include "src/x87/codegen-x87.h" // NOLINT
62 #else
63 #error Unsupported target architecture.
64 #endif
65 
66 namespace v8 {
67 namespace internal {
68 
69 
70 class CompilationInfo;
71 
72 
74  public:
75  // Printing of AST, etc. as requested by flags.
76  static void MakeCodePrologue(CompilationInfo* info, const char* kind);
77 
78  // Allocate and install the code.
81  CompilationInfo* info);
82 
83  // Print the code after compiling it.
84  static void PrintCode(Handle<Code> code, CompilationInfo* info);
85 
86  static bool RecordPositions(MacroAssembler* masm,
87  int pos,
88  bool right_here = false);
89 
90  private:
92 };
93 
94 
95 // Results of the library implementation of transcendental functions may differ
96 // from the one we use in our generated code. Therefore we use the same
97 // generated code both in runtime and compiled code.
98 typedef double (*UnaryMathFunction)(double x);
99 
102 
103 
104 double modulo(double x, double y);
105 
106 // Custom implementation of math functions.
107 double fast_exp(double input);
108 double fast_sqrt(double input);
109 #ifdef _WIN64
110 void init_modulo_function();
111 #endif
114 
115 
117  public:
118  // If |mode| is set to DONT_TRACK_ALLOCATION_SITE,
119  // |allocation_memento_found| may be NULL.
121  MacroAssembler* masm,
122  Register receiver,
123  Register key,
124  Register value,
125  Register target_map,
127  Label* allocation_memento_found);
128  static void GenerateSmiToDouble(
129  MacroAssembler* masm,
130  Register receiver,
131  Register key,
132  Register value,
133  Register target_map,
135  Label* fail);
137  MacroAssembler* masm,
138  Register receiver,
139  Register key,
140  Register value,
141  Register target_map,
143  Label* fail);
144 
145  private:
147 };
148 
149 static const int kNumberDictionaryProbes = 4;
150 
151 
153  public:
155 
157  bool IsYoung(byte* candidate) const {
158  return memcmp(candidate,
160  young_sequence_.length()) == 0;
161  }
162  void CopyYoungSequenceTo(byte* new_buffer) const {
164  }
165 
166 #ifdef DEBUG
167  bool IsOld(byte* candidate) const;
168 #endif
169 
170  protected:
172 #ifdef DEBUG
173 #ifdef V8_TARGET_ARCH_ARM64
175 #endif
176 #endif
177 };
178 
179 } } // namespace v8::internal
180 
181 #endif // V8_CODEGEN_H_
const EmbeddedVector< byte, kNoCodeAgeSequenceLength > young_sequence_
Definition: codegen.h:171
uint32_t young_sequence_length() const
Definition: codegen.h:156
bool IsYoung(byte *candidate) const
Definition: codegen.h:157
void CopyYoungSequenceTo(byte *new_buffer) const
Definition: codegen.h:162
static void PrintCode(Handle< Code > code, CompilationInfo *info)
Definition: codegen.cc:163
static bool RecordPositions(MacroAssembler *masm, int pos, bool right_here=false)
Definition: codegen.cc:225
static void MakeCodePrologue(CompilationInfo *info, const char *kind)
Definition: codegen.cc:97
static Handle< Code > MakeCodeEpilogue(MacroAssembler *masm, Code::Flags flags, CompilationInfo *info)
Definition: codegen.cc:139
DISALLOW_COPY_AND_ASSIGN(CodeGenerator)
DISALLOW_COPY_AND_ASSIGN(ElementsTransitionGenerator)
static void GenerateSmiToDouble(MacroAssembler *masm, Register receiver, Register key, Register value, Register target_map, AllocationSiteMode mode, Label *fail)
static void GenerateMapChangeElementsTransition(MacroAssembler *masm, Register receiver, Register key, Register value, Register target_map, AllocationSiteMode mode, Label *allocation_memento_found)
static void GenerateDoubleToObject(MacroAssembler *masm, Register receiver, Register key, Register value, Register target_map, AllocationSiteMode mode, Label *fail)
T * start() const
Definition: vector.h:47
int length() const
Definition: vector.h:41
TypeofState
Definition: codegen.h:46
@ NOT_INSIDE_TYPEOF
Definition: codegen.h:46
@ INSIDE_TYPEOF
Definition: codegen.h:46
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
double fast_exp(double input)
double fast_sqrt(double input)
double modulo(double x, double y)
Definition: codegen.cc:50
void lazily_initialize_fast_exp()
Definition: codegen.cc:71
UnaryMathFunction CreateExpFunction()
void init_fast_sqrt_function()
static const int kNumberDictionaryProbes
Definition: codegen.h:149
UnaryMathFunction CreateSqrtFunction()
double(* UnaryMathFunction)(double x)
Definition: codegen.h:98
void CopyBytes(uint8_t *target, uint8_t *source)
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20