V8 Project
handler-compiler.h
Go to the documentation of this file.
1 // Copyright 2014 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_IC_HANDLER_COMPILER_H_
6 #define V8_IC_HANDLER_COMPILER_H_
7 
9 #include "src/ic/ic-state.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 class CallOptimization;
15 
17 
19  public:
21  CacheHolderFlag cache_holder, Code::StubType type);
22 
23  protected:
26  CacheHolderFlag cache_holder)
27  : PropertyAccessCompiler(isolate, kind, cache_holder),
28  type_(type),
29  holder_(holder) {}
30 
32 
34  Label* miss) {
35  UNREACHABLE();
36  return receiver();
37  }
38 
39  virtual void FrontendFooter(Handle<Name> name, Label* miss) { UNREACHABLE(); }
40 
43  Register scratch1, Register scratch2);
44 
45  // TODO(verwaest): Make non-static.
47  const CallOptimization& optimization,
48  Handle<Map> receiver_map, Register receiver,
49  Register scratch, bool is_store, int argc,
50  Register* values);
51 
52  // Helper function used to check that the dictionary doesn't contain
53  // the property. This function may return false negatives, so miss_label
54  // must always call a backup property check that is complete.
55  // This function is safe to call if the receiver has fast properties.
56  // Name must be unique and receiver must be a heap object.
58  Label* miss_label,
59  Register receiver,
61  Register r1);
62 
63  // Generate code to check that a global property cell is empty. Create
64  // the property cell at compilation time if no cell exists for the
65  // property.
68  Handle<Name> name, Register scratch,
69  Label* miss);
70 
71  // Generates code that verifies that the property holder has not changed
72  // (checking maps of objects in the prototype chain for fast and global
73  // objects or doing negative lookup for slow objects, ensures that the
74  // property cells for global objects are still empty) and checks that the map
75  // of the holder has not changed. If necessary the function also generates
76  // code for security check in case of global object holders. Helps to make
77  // sure that the current IC is still valid.
78  //
79  // The scratch and holder registers are always clobbered, but the object
80  // register is only clobbered if it the same as the holder register. The
81  // function returns a register containing the holder - either object_reg or
82  // holder_reg.
83  Register CheckPrototypes(Register object_reg, Register holder_reg,
84  Register scratch1, Register scratch2,
85  Handle<Name> name, Label* miss,
87 
91  Handle<HeapType> type() const { return type_; }
92  Handle<JSObject> holder() const { return holder_; }
93 
94  private:
97 };
98 
99 
101  public:
104  CacheHolderFlag cache_holder)
105  : PropertyHandlerCompiler(isolate, Code::LOAD_IC, type, holder,
106  cache_holder) {}
107 
109 
110  Handle<Code> CompileLoadField(Handle<Name> name, FieldIndex index);
111 
114 
116  const CallOptimization& call_optimization);
117 
118  Handle<Code> CompileLoadConstant(Handle<Name> name, int constant_index);
119 
120  // The LookupIterator is used to perform a lookup behind the interceptor. If
121  // the iterator points to a LookupIterator::PROPERTY, its access will be
122  // inlined.
123  Handle<Code> CompileLoadInterceptor(LookupIterator* it);
124 
126  Handle<JSFunction> getter);
127 
129  bool is_configurable);
130 
131  // Static interface
134 
136  Register receiver,
137  Handle<JSFunction> getter);
138 
142  }
143 
145  Register receiver,
146  Register scratch1,
147  Register scratch2,
148  Label* miss_label);
149 
150  // These constants describe the structure of the interceptor arguments on the
151  // stack. The arguments are pushed by the (platform-specific)
152  // PushInterceptorArguments and read by LoadPropertyWithInterceptorOnly and
153  // LoadWithInterceptor.
154  static const int kInterceptorArgsNameIndex = 0;
155  static const int kInterceptorArgsInfoIndex = 1;
156  static const int kInterceptorArgsThisIndex = 2;
157  static const int kInterceptorArgsHolderIndex = 3;
158  static const int kInterceptorArgsLength = 4;
159 
160  protected:
161  virtual Register FrontendHeader(Register object_reg, Handle<Name> name,
162  Label* miss);
163 
164  virtual void FrontendFooter(Handle<Name> name, Label* miss);
165 
166  private:
171  void GenerateLoadCallback(const CallOptimization& call_optimization,
172  Handle<Map> receiver_map);
174  void GenerateLoadInterceptorWithFollowup(LookupIterator* it,
175  Register holder_reg);
176  void GenerateLoadPostInterceptor(LookupIterator* it, Register reg);
177 
178  // Generates prototype loading code that uses the objects from the
179  // context we were in when this function was called. If the context
180  // has changed, a jump to miss is performed. This ties the generated
181  // code to a particular context and so must not be used in cases
182  // where the generated code is not allowed to have references to
183  // objects from a context.
185  int index,
186  Register prototype,
187  Label* miss);
188 
189 
190  Register scratch4() { return registers_[5]; }
191 };
192 
193 
195  public:
198  : PropertyHandlerCompiler(isolate, Code::STORE_IC, type, holder,
199  kCacheOnReceiver) {}
200 
202 
205  Handle<Code> CompileStoreField(LookupIterator* it);
209  const CallOptimization& call_optimization);
211  Handle<JSFunction> setter);
213 
215  Handle<HeapType> type, Register receiver,
216  Handle<JSFunction> setter);
217 
221  }
222 
223  static void GenerateSlow(MacroAssembler* masm);
224 
225  protected:
226  virtual Register FrontendHeader(Register object_reg, Handle<Name> name,
227  Label* miss);
228 
229  virtual void FrontendFooter(Handle<Name> name, Label* miss);
230  void GenerateRestoreName(Label* label, Handle<Name> name);
231 
232  private:
234  Register receiver_reg, Register name_reg,
235  Register value_reg, Register scratch1,
236  Register scratch2, Register scratch3,
237  Label* miss_label, Label* slow);
238 
239  void GenerateStoreField(LookupIterator* lookup, Register value_reg,
240  Label* miss_label);
241 
243  switch (kind) {
244  case Code::STORE_IC:
245  return Builtins::kStoreIC_Slow;
246  case Code::KEYED_STORE_IC:
247  return Builtins::kKeyedStoreIC_Slow;
248  default:
249  UNREACHABLE();
250  }
251  return Builtins::kStoreIC_Slow;
252  }
253 
254  static Register value();
255 };
256 
257 
259  public:
260  explicit ElementHandlerCompiler(Isolate* isolate)
261  : PropertyHandlerCompiler(isolate, Code::KEYED_LOAD_IC,
262  Handle<HeapType>::null(),
263  Handle<JSObject>::null(), kCacheOnReceiver) {}
264 
266 
267  void CompileElementHandlers(MapHandleList* receiver_maps,
268  CodeHandleList* handlers);
269 
270  static void GenerateStoreSlow(MacroAssembler* masm);
271 };
272 }
273 } // namespace v8::internal
274 
275 #endif // V8_IC_HANDLER_COMPILER_H_
static void GenerateStoreSlow(MacroAssembler *masm)
void CompileElementHandlers(MapHandleList *receiver_maps, CodeHandleList *handlers)
void GenerateLoadCallback(const CallOptimization &call_optimization, Handle< Map > receiver_map)
static Handle< Code > ComputeLoadNonexistent(Handle< Name > name, Handle< HeapType > type)
Handle< Code > CompileLoadCallback(Handle< Name > name, Handle< ExecutableAccessorInfo > callback)
Handle< Code > CompileLoadGlobal(Handle< PropertyCell > cell, Handle< Name > name, bool is_configurable)
static void GenerateLoadViaGetterForDeopt(MacroAssembler *masm)
virtual void FrontendFooter(Handle< Name > name, Label *miss)
Handle< Code > CompileLoadField(Handle< Name > name, FieldIndex index)
Handle< Code > CompileLoadNonexistent(Handle< Name > name)
static void GenerateDirectLoadGlobalFunctionPrototype(MacroAssembler *masm, int index, Register prototype, Label *miss)
NamedLoadHandlerCompiler(Isolate *isolate, Handle< HeapType > type, Handle< JSObject > holder, CacheHolderFlag cache_holder)
void GenerateLoadInterceptorWithFollowup(LookupIterator *it, Register holder_reg)
Handle< Code > CompileLoadInterceptor(LookupIterator *it)
virtual Register FrontendHeader(Register object_reg, Handle< Name > name, Label *miss)
void GenerateLoadConstant(Handle< Object > value)
Handle< Code > CompileLoadViaGetter(Handle< Name > name, Handle< JSFunction > getter)
void GenerateLoadInterceptor(Register holder_reg)
static void GenerateLoadFunctionPrototype(MacroAssembler *masm, Register receiver, Register scratch1, Register scratch2, Label *miss_label)
Handle< Code > CompileLoadConstant(Handle< Name > name, int constant_index)
void GenerateLoadPostInterceptor(LookupIterator *it, Register reg)
static void GenerateLoadViaGetter(MacroAssembler *masm, Handle< HeapType > type, Register receiver, Handle< JSFunction > getter)
void GenerateLoadCallback(Register reg, Handle< ExecutableAccessorInfo > callback)
Handle< Code > CompileStoreInterceptor(Handle< Name > name)
static void GenerateStoreViaSetterForDeopt(MacroAssembler *masm)
Handle< Code > CompileStoreViaSetter(Handle< JSObject > object, Handle< Name > name, Handle< JSFunction > setter)
virtual void FrontendFooter(Handle< Name > name, Label *miss)
void GenerateStoreField(LookupIterator *lookup, Register value_reg, Label *miss_label)
Handle< Code > CompileStoreCallback(Handle< JSObject > object, Handle< Name > name, Handle< ExecutableAccessorInfo > callback)
static void GenerateSlow(MacroAssembler *masm)
NamedStoreHandlerCompiler(Isolate *isolate, Handle< HeapType > type, Handle< JSObject > holder)
void GenerateRestoreName(Label *label, Handle< Name > name)
Handle< Code > CompileStoreField(LookupIterator *it)
static Builtins::Name SlowBuiltin(Code::Kind kind)
void GenerateStoreTransition(Handle< Map > transition, Handle< Name > name, Register receiver_reg, Register name_reg, Register value_reg, Register scratch1, Register scratch2, Register scratch3, Label *miss_label, Label *slow)
static void GenerateStoreViaSetter(MacroAssembler *masm, Handle< HeapType > type, Register receiver, Handle< JSFunction > setter)
virtual Register FrontendHeader(Register object_reg, Handle< Name > name, Label *miss)
Handle< Code > CompileStoreTransition(Handle< Map > transition, Handle< Name > name)
Handle< JSObject > holder() const
void NonexistentFrontendHeader(Handle< Name > name, Label *miss, Register scratch1, Register scratch2)
void set_type_for_object(Handle< Object > object)
virtual void FrontendFooter(Handle< Name > name, Label *miss)
PropertyHandlerCompiler(Isolate *isolate, Code::Kind kind, Handle< HeapType > type, Handle< JSObject > holder, CacheHolderFlag cache_holder)
Register CheckPrototypes(Register object_reg, Register holder_reg, Register scratch1, Register scratch2, Handle< Name > name, Label *miss, PrototypeCheckType check=CHECK_ALL_MAPS)
Handle< Code > GetCode(Code::Kind kind, Code::StubType type, Handle< Name > name)
Handle< HeapType > type() const
static Handle< Code > Find(Handle< Name > name, Handle< Map > map, Code::Kind kind, CacheHolderFlag cache_holder, Code::StubType type)
static void GenerateDictionaryNegativeLookup(MacroAssembler *masm, Label *miss_label, Register receiver, Handle< Name > name, Register r0, Register r1)
static void GenerateFastApiCall(MacroAssembler *masm, const CallOptimization &optimization, Handle< Map > receiver_map, Register receiver, Register scratch, bool is_store, int argc, Register *values)
Register Frontend(Register object_reg, Handle< Name > name)
static void GenerateCheckPropertyCell(MacroAssembler *masm, Handle< JSGlobalObject > global, Handle< Name > name, Register scratch, Label *miss)
virtual Register FrontendHeader(Register object_reg, Handle< Name > name, Label *miss)
void set_holder(Handle< JSObject > holder)
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 map
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 enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
#define UNREACHABLE()
Definition: logging.h:30
const Register r0
@ kCacheOnReceiver
Definition: globals.h:488
const Register r1
const Register no_reg
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20