v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
macro-assembler.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_MACRO_ASSEMBLER_H_
29 #define V8_MACRO_ASSEMBLER_H_
30 
31 
32 // Helper types to make boolean flag easier to read at call-site.
33 enum InvokeFlag {
36 };
37 
38 
39 // Flags used for the AllocateInNewSpace functions.
41  // No special flags.
43  // Return the pointer to the allocated already tagged as a heap object.
44  TAG_OBJECT = 1 << 0,
45  // The content of the result register already contains the allocation top in
46  // new space.
48  // Specify that the requested size of the space to allocate is specified in
49  // words instead of bytes.
50  SIZE_IN_WORDS = 1 << 2,
51  // Align the allocation to a multiple of kDoubleSize
52  DOUBLE_ALIGNMENT = 1 << 3,
53  // Directly allocate in old pointer space
55  // Directly allocate in old data space
57 };
58 
59 
60 // Invalid depth in prototype chain.
61 const int kInvalidProtoDepth = -1;
62 
63 #if V8_TARGET_ARCH_IA32
64 #include "assembler.h"
65 #include "ia32/assembler-ia32.h"
67 #include "code.h" // must be after assembler_*.h
69 #elif V8_TARGET_ARCH_X64
70 #include "assembler.h"
71 #include "x64/assembler-x64.h"
72 #include "x64/assembler-x64-inl.h"
73 #include "code.h" // must be after assembler_*.h
75 #elif V8_TARGET_ARCH_ARM64
76 #include "arm64/constants-arm64.h"
77 #include "assembler.h"
78 #include "arm64/assembler-arm64.h"
80 #include "code.h" // must be after assembler_*.h
83 #elif V8_TARGET_ARCH_ARM
84 #include "arm/constants-arm.h"
85 #include "assembler.h"
86 #include "arm/assembler-arm.h"
87 #include "arm/assembler-arm-inl.h"
88 #include "code.h" // must be after assembler_*.h
90 #elif V8_TARGET_ARCH_MIPS
91 #include "mips/constants-mips.h"
92 #include "assembler.h"
93 #include "mips/assembler-mips.h"
95 #include "code.h" // must be after assembler_*.h
97 #else
98 #error Unsupported target architecture.
99 #endif
100 
101 namespace v8 {
102 namespace internal {
103 
104 class FrameScope {
105  public:
107  : masm_(masm), type_(type), old_has_frame_(masm->has_frame()) {
108  masm->set_has_frame(true);
109  if (type != StackFrame::MANUAL && type_ != StackFrame::NONE) {
110  masm->EnterFrame(type);
111  }
112  }
113 
115  if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) {
116  masm_->LeaveFrame(type_);
117  }
118  masm_->set_has_frame(old_has_frame_);
119  }
120 
121  // Normally we generate the leave-frame code when this object goes
122  // out of scope. Sometimes we may need to generate the code somewhere else
123  // in addition. Calling this will achieve that, but the object stays in
124  // scope, the MacroAssembler is still marked as being in a frame scope, and
125  // the code will be generated again when it goes out of scope.
127  ASSERT(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE);
128  masm_->LeaveFrame(type_);
129  }
130 
131  private:
132  MacroAssembler* masm_;
133  StackFrame::Type type_;
134  bool old_has_frame_;
135 };
136 
137 
139  public:
141  : FrameScope(masm, StackFrame::NONE) { }
142 };
143 
144 
146  public:
148  : masm_(masm), saved_(masm->has_frame()) {
149  masm->set_has_frame(false);
150  }
151 
153  masm_->set_has_frame(saved_);
154  }
155 
156  private:
157  MacroAssembler* masm_;
158  bool saved_;
159 };
160 
161 
162 // Support for "structured" code comments.
163 #ifdef DEBUG
164 
165 class Comment {
166  public:
167  Comment(MacroAssembler* masm, const char* msg);
168  ~Comment();
169 
170  private:
171  MacroAssembler* masm_;
172  const char* msg_;
173 };
174 
175 #else
176 
177 class Comment {
178  public:
179  Comment(MacroAssembler*, const char*) {}
180 };
181 
182 #endif // DEBUG
183 
184 
186  public:
187  static ExternalReference GetAllocationTopReference(
188  Isolate* isolate, AllocationFlags flags) {
189  if ((flags & PRETENURE_OLD_POINTER_SPACE) != 0) {
190  return ExternalReference::old_pointer_space_allocation_top_address(
191  isolate);
192  } else if ((flags & PRETENURE_OLD_DATA_SPACE) != 0) {
193  return ExternalReference::old_data_space_allocation_top_address(isolate);
194  }
195  return ExternalReference::new_space_allocation_top_address(isolate);
196  }
197 
198 
199  static ExternalReference GetAllocationLimitReference(
200  Isolate* isolate, AllocationFlags flags) {
201  if ((flags & PRETENURE_OLD_POINTER_SPACE) != 0) {
202  return ExternalReference::old_pointer_space_allocation_limit_address(
203  isolate);
204  } else if ((flags & PRETENURE_OLD_DATA_SPACE) != 0) {
205  return ExternalReference::old_data_space_allocation_limit_address(
206  isolate);
207  }
208  return ExternalReference::new_space_allocation_limit_address(isolate);
209  }
210 };
211 
212 
213 } } // namespace v8::internal
214 
215 #endif // V8_MACRO_ASSEMBLER_H_
TypeImpl< ZoneTypeConfig > Type
void EnterFrame(StackFrame::Type type, bool load_constant_pool=false)
#define ASSERT(condition)
Definition: checks.h:329
HANDLE HANDLE LPSTACKFRAME64 StackFrame
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
Definition: flags.cc:665
NoCurrentFrameScope(MacroAssembler *masm)
FrameScope(MacroAssembler *masm, StackFrame::Type type)
static ExternalReference GetAllocationLimitReference(Isolate *isolate, AllocationFlags flags)
InvokeFlag
AllocationFlags
static ExternalReference GetAllocationTopReference(Isolate *isolate, AllocationFlags flags)
const int kInvalidProtoDepth
int LeaveFrame(StackFrame::Type type)
Comment(MacroAssembler *, const char *)