OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 struct Entry { | 69 struct Entry { |
70 String* key; | 70 String* key; |
71 Code* value; | 71 Code* value; |
72 }; | 72 }; |
73 | 73 |
74 void Initialize(bool create_heap_objects); | 74 void Initialize(bool create_heap_objects); |
75 | 75 |
76 | 76 |
77 // Computes the right stub matching. Inserts the result in the | 77 // Computes the right stub matching. Inserts the result in the |
78 // cache before returning. This might compile a stub if needed. | 78 // cache before returning. This might compile a stub if needed. |
79 MUST_USE_RESULT MaybeObject* ComputeLoadNonexistent( | 79 Handle<Code> ComputeLoadNonexistent(Handle<String> name, |
80 String* name, | 80 Handle<JSObject> receiver); |
81 JSObject* receiver); | |
82 | 81 |
83 MUST_USE_RESULT MaybeObject* ComputeLoadField(String* name, | 82 Handle<Code> ComputeLoadField(Handle<String> name, |
84 JSObject* receiver, | 83 Handle<JSObject> receiver, |
85 JSObject* holder, | 84 Handle<JSObject> holder, |
86 int field_index); | 85 int field_index); |
87 | 86 |
88 MUST_USE_RESULT MaybeObject* ComputeLoadCallback( | 87 Handle<Code> ComputeLoadCallback(Handle<String> name, |
89 String* name, | 88 Handle<JSObject> receiver, |
90 JSObject* receiver, | 89 Handle<JSObject> holder, |
91 JSObject* holder, | 90 Handle<AccessorInfo> callback); |
92 AccessorInfo* callback); | |
93 | 91 |
94 MUST_USE_RESULT MaybeObject* ComputeLoadConstant(String* name, | 92 Handle<Code> ComputeLoadConstant(Handle<String> name, |
95 JSObject* receiver, | 93 Handle<JSObject> receiver, |
96 JSObject* holder, | 94 Handle<JSObject> holder, |
97 Object* value); | 95 Handle<Object> value); |
98 | 96 |
99 MUST_USE_RESULT MaybeObject* ComputeLoadInterceptor( | 97 Handle<Code> ComputeLoadInterceptor(Handle<String> name, |
100 String* name, | 98 Handle<JSObject> receiver, |
101 JSObject* receiver, | 99 Handle<JSObject> holder); |
102 JSObject* holder); | |
103 | 100 |
104 MUST_USE_RESULT MaybeObject* ComputeLoadNormal(); | 101 Handle<Code> ComputeLoadNormal(); |
105 | 102 |
106 | 103 Handle<Code> ComputeLoadGlobal(Handle<String> name, |
107 MUST_USE_RESULT MaybeObject* ComputeLoadGlobal( | 104 Handle<JSObject> receiver, |
108 String* name, | 105 Handle<GlobalObject> holder, |
109 JSObject* receiver, | 106 Handle<JSGlobalPropertyCell> cell, |
110 GlobalObject* holder, | 107 bool is_dont_delete); |
111 JSGlobalPropertyCell* cell, | |
112 bool is_dont_delete); | |
113 | |
114 | 108 |
115 // --- | 109 // --- |
116 | 110 |
117 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadField(String* name, | 111 Handle<Code> ComputeKeyedLoadField(Handle<String> name, |
118 JSObject* receiver, | 112 Handle<JSObject> receiver, |
119 JSObject* holder, | 113 Handle<JSObject> holder, |
120 int field_index); | 114 int field_index); |
121 | 115 |
122 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadCallback( | 116 Handle<Code> ComputeKeyedLoadCallback(Handle<String> name, |
123 String* name, | 117 Handle<JSObject> receiver, |
124 JSObject* receiver, | 118 Handle<JSObject> holder, |
125 JSObject* holder, | 119 Handle<AccessorInfo> callback); |
126 AccessorInfo* callback); | |
127 | 120 |
128 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadConstant( | 121 Handle<Code> ComputeKeyedLoadConstant(Handle<String> name, |
129 String* name, | 122 Handle<JSObject> receiver, |
130 JSObject* receiver, | 123 Handle<JSObject> holder, |
131 JSObject* holder, | 124 Handle<Object> value); |
132 Object* value); | |
133 | 125 |
134 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadInterceptor( | 126 Handle<Code> ComputeKeyedLoadInterceptor(Handle<String> name, |
135 String* name, | 127 Handle<JSObject> receiver, |
136 JSObject* receiver, | 128 Handle<JSObject> holder); |
137 JSObject* holder); | |
138 | 129 |
139 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadArrayLength( | 130 Handle<Code> ComputeKeyedLoadArrayLength(Handle<String> name, |
140 String* name, | 131 Handle<JSArray> receiver); |
141 JSArray* receiver); | |
142 | 132 |
143 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadStringLength( | 133 Handle<Code> ComputeKeyedLoadStringLength(Handle<String> name, |
144 String* name, | 134 Handle<String> receiver); |
145 String* receiver); | |
146 | 135 |
147 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadFunctionPrototype( | 136 Handle<Code> ComputeKeyedLoadFunctionPrototype(Handle<String> name, |
148 String* name, | 137 Handle<JSFunction> receiver); |
149 JSFunction* receiver); | |
150 | 138 |
151 // --- | 139 // --- |
152 | 140 |
153 MUST_USE_RESULT MaybeObject* ComputeStoreField( | 141 Handle<Code> ComputeStoreField(Handle<String> name, |
154 String* name, | 142 Handle<JSObject> receiver, |
155 JSObject* receiver, | 143 int field_index, |
156 int field_index, | 144 Handle<Map> transition, |
157 Map* transition, | 145 StrictModeFlag strict_mode); |
158 StrictModeFlag strict_mode); | |
159 | 146 |
160 MUST_USE_RESULT MaybeObject* ComputeStoreNormal( | 147 Handle<Code> ComputeStoreNormal(StrictModeFlag strict_mode); |
161 StrictModeFlag strict_mode); | |
162 | 148 |
163 MUST_USE_RESULT MaybeObject* ComputeStoreGlobal( | 149 Handle<Code> ComputeStoreGlobal(Handle<String> name, |
164 String* name, | 150 Handle<GlobalObject> receiver, |
165 GlobalObject* receiver, | 151 Handle<JSGlobalPropertyCell> cell, |
166 JSGlobalPropertyCell* cell, | 152 StrictModeFlag strict_mode); |
167 StrictModeFlag strict_mode); | |
168 | 153 |
169 MUST_USE_RESULT MaybeObject* ComputeStoreCallback( | 154 Handle<Code> ComputeStoreCallback(Handle<String> name, |
170 String* name, | 155 Handle<JSObject> receiver, |
171 JSObject* receiver, | 156 Handle<AccessorInfo> callback, |
172 AccessorInfo* callback, | 157 StrictModeFlag strict_mode); |
173 StrictModeFlag strict_mode); | |
174 | 158 |
175 MUST_USE_RESULT MaybeObject* ComputeStoreInterceptor( | 159 Handle<Code> ComputeStoreInterceptor(Handle<String> name, |
176 String* name, | 160 Handle<JSObject> receiver, |
177 JSObject* receiver, | 161 StrictModeFlag strict_mode); |
178 StrictModeFlag strict_mode); | |
179 | 162 |
180 // --- | 163 // --- |
181 | 164 |
182 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreField( | 165 Handle<Code> ComputeKeyedStoreField(Handle<String> name, |
183 String* name, | 166 Handle<JSObject> receiver, |
184 JSObject* receiver, | 167 int field_index, |
185 int field_index, | 168 Handle<Map> transition, |
186 Map* transition, | 169 StrictModeFlag strict_mode); |
187 StrictModeFlag strict_mode); | |
188 | 170 |
189 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreElement( | 171 Handle<Code> ComputeKeyedLoadOrStoreElement(Handle<JSObject> receiver, |
190 JSObject* receiver, | 172 KeyedIC::StubKind stub_kind, |
191 KeyedIC::StubKind stub_kind, | 173 StrictModeFlag strict_mode); |
192 StrictModeFlag strict_mode); | |
193 | 174 |
194 // --- | 175 // --- |
195 | 176 |
196 MUST_USE_RESULT MaybeObject* ComputeCallField( | 177 Handle<Code> ComputeCallField(int argc, |
197 int argc, | 178 Code::Kind, |
198 Code::Kind, | 179 Code::ExtraICState extra_state, |
199 Code::ExtraICState extra_ic_state, | 180 Handle<String> name, |
200 String* name, | 181 Handle<Object> object, |
201 Object* object, | 182 Handle<JSObject> holder, |
202 JSObject* holder, | 183 int index); |
203 int index); | |
204 | 184 |
205 MUST_USE_RESULT MaybeObject* ComputeCallConstant( | 185 Handle<Code> ComputeCallConstant(int argc, |
206 int argc, | 186 Code::Kind, |
207 Code::Kind, | 187 Code::ExtraICState extra_state, |
208 Code::ExtraICState extra_ic_state, | 188 Handle<String> name, |
209 String* name, | 189 Handle<Object> object, |
210 Object* object, | 190 Handle<JSObject> holder, |
211 JSObject* holder, | 191 Handle<JSFunction> function); |
212 JSFunction* function); | |
213 | 192 |
214 MUST_USE_RESULT MaybeObject* ComputeCallNormal( | 193 Handle<Code> ComputeCallInterceptor(int argc, |
215 int argc, | 194 Code::Kind, |
216 Code::Kind, | 195 Code::ExtraICState extra_state, |
217 Code::ExtraICState extra_ic_state, | 196 Handle<String> name, |
218 String* name, | 197 Handle<Object> object, |
219 JSObject* receiver); | 198 Handle<JSObject> holder); |
220 | 199 |
221 MUST_USE_RESULT MaybeObject* ComputeCallInterceptor( | 200 Handle<Code> ComputeCallGlobal(int argc, |
222 int argc, | 201 Code::Kind, |
223 Code::Kind, | 202 Code::ExtraICState extra_state, |
224 Code::ExtraICState extra_ic_state, | 203 Handle<String> name, |
225 String* name, | 204 Handle<JSObject> receiver, |
226 Object* object, | 205 Handle<GlobalObject> holder, |
227 JSObject* holder); | 206 Handle<JSGlobalPropertyCell> cell, |
228 | 207 Handle<JSFunction> function); |
229 MUST_USE_RESULT MaybeObject* ComputeCallGlobal( | |
230 int argc, | |
231 Code::Kind, | |
232 Code::ExtraICState extra_ic_state, | |
233 String* name, | |
234 JSObject* receiver, | |
235 GlobalObject* holder, | |
236 JSGlobalPropertyCell* cell, | |
237 JSFunction* function); | |
238 | 208 |
239 // --- | 209 // --- |
240 | 210 |
241 MUST_USE_RESULT MaybeObject* ComputeCallInitialize(int argc, | 211 Handle<Code> ComputeCallInitialize(int argc, RelocInfo::Mode mode); |
242 RelocInfo::Mode mode, | |
243 Code::Kind kind); | |
244 | |
245 Handle<Code> ComputeCallInitialize(int argc, | |
246 RelocInfo::Mode mode); | |
247 | 212 |
248 Handle<Code> ComputeKeyedCallInitialize(int argc); | 213 Handle<Code> ComputeKeyedCallInitialize(int argc); |
249 | 214 |
250 MUST_USE_RESULT MaybeObject* ComputeCallPreMonomorphic( | 215 Handle<Code> ComputeCallPreMonomorphic(int argc, |
251 int argc, | 216 Code::Kind kind, |
252 Code::Kind kind, | 217 Code::ExtraICState extra_state); |
253 Code::ExtraICState extra_ic_state); | |
254 | 218 |
255 MUST_USE_RESULT MaybeObject* ComputeCallNormal(int argc, | 219 Handle<Code> ComputeCallNormal(int argc, |
256 Code::Kind kind, | 220 Code::Kind kind, |
257 Code::ExtraICState state); | 221 Code::ExtraICState state); |
258 | 222 |
259 MUST_USE_RESULT MaybeObject* ComputeCallArguments(int argc, | 223 Handle<Code> ComputeCallArguments(int argc, Code::Kind kind); |
260 Code::Kind kind); | |
261 | 224 |
262 MUST_USE_RESULT MaybeObject* ComputeCallMegamorphic(int argc, | 225 Handle<Code> ComputeCallMegamorphic(int argc, |
263 Code::Kind kind, | 226 Code::Kind kind, |
264 Code::ExtraICState state); | 227 Code::ExtraICState state); |
265 | 228 |
266 MUST_USE_RESULT MaybeObject* ComputeCallMiss(int argc, | 229 Handle<Code> ComputeCallMiss(int argc, |
267 Code::Kind kind, | 230 Code::Kind kind, |
268 Code::ExtraICState state); | 231 Code::ExtraICState state); |
| 232 |
| 233 MUST_USE_RESULT MaybeObject* TryComputeCallMiss(int argc, |
| 234 Code::Kind kind, |
| 235 Code::ExtraICState state); |
269 | 236 |
270 // Finds the Code object stored in the Heap::non_monomorphic_cache(). | 237 // Finds the Code object stored in the Heap::non_monomorphic_cache(). |
271 MUST_USE_RESULT Code* FindCallInitialize(int argc, | 238 Code* FindCallInitialize(int argc, RelocInfo::Mode mode, Code::Kind kind); |
272 RelocInfo::Mode mode, | |
273 Code::Kind kind); | |
274 | 239 |
275 #ifdef ENABLE_DEBUGGER_SUPPORT | 240 #ifdef ENABLE_DEBUGGER_SUPPORT |
276 MUST_USE_RESULT MaybeObject* ComputeCallDebugBreak(int argc, Code::Kind kind); | 241 Handle<Code> ComputeCallDebugBreak(int argc, Code::Kind kind); |
277 | 242 |
278 MUST_USE_RESULT MaybeObject* ComputeCallDebugPrepareStepIn(int argc, | 243 Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind); |
279 Code::Kind kind); | |
280 #endif | 244 #endif |
281 | 245 |
282 // Update cache for entry hash(name, map). | 246 // Update cache for entry hash(name, map). |
283 Code* Set(String* name, Map* map, Code* code); | 247 Code* Set(String* name, Map* map, Code* code); |
284 | 248 |
285 // Clear the lookup table (@ mark compact collection). | 249 // Clear the lookup table (@ mark compact collection). |
286 void Clear(); | 250 void Clear(); |
287 | 251 |
288 // Collect all maps that match the name and flags. | 252 // Collect all maps that match the name and flags. |
289 void CollectMatchingMaps(SmallMapList* types, | 253 void CollectMatchingMaps(SmallMapList* types, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 switch (table) { | 287 switch (table) { |
324 case StubCache::kPrimary: return StubCache::primary_; | 288 case StubCache::kPrimary: return StubCache::primary_; |
325 case StubCache::kSecondary: return StubCache::secondary_; | 289 case StubCache::kSecondary: return StubCache::secondary_; |
326 } | 290 } |
327 UNREACHABLE(); | 291 UNREACHABLE(); |
328 return NULL; | 292 return NULL; |
329 } | 293 } |
330 | 294 |
331 Isolate* isolate() { return isolate_; } | 295 Isolate* isolate() { return isolate_; } |
332 Heap* heap() { return isolate()->heap(); } | 296 Heap* heap() { return isolate()->heap(); } |
| 297 Factory* factory() { return isolate()->factory(); } |
333 | 298 |
334 private: | 299 private: |
335 explicit StubCache(Isolate* isolate); | 300 explicit StubCache(Isolate* isolate); |
336 | 301 |
337 friend class Isolate; | 302 Handle<Code> ComputeCallInitialize(int argc, |
338 friend class SCTableReference; | 303 RelocInfo::Mode mode, |
339 static const int kPrimaryTableSize = 2048; | 304 Code::Kind kind); |
340 static const int kSecondaryTableSize = 512; | |
341 Entry primary_[kPrimaryTableSize]; | |
342 Entry secondary_[kSecondaryTableSize]; | |
343 | 305 |
344 // Computes the hashed offsets for primary and secondary caches. | 306 // Computes the hashed offsets for primary and secondary caches. |
345 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { | 307 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { |
346 // This works well because the heap object tag size and the hash | 308 // This works well because the heap object tag size and the hash |
347 // shift are equal. Shifting down the length field to get the | 309 // shift are equal. Shifting down the length field to get the |
348 // hash code would effectively throw away two bits of the hash | 310 // hash code would effectively throw away two bits of the hash |
349 // code. | 311 // code. |
350 STATIC_ASSERT(kHeapObjectTagSize == String::kHashShift); | 312 STATIC_ASSERT(kHeapObjectTagSize == String::kHashShift); |
351 // Compute the hash of the name (use entire hash field). | 313 // Compute the hash of the name (use entire hash field). |
352 ASSERT(name->HasHashCode()); | 314 ASSERT(name->HasHashCode()); |
(...skipping 24 matching lines...) Expand all Loading... |
377 // we do in generated code. We generate an hash code that already | 339 // we do in generated code. We generate an hash code that already |
378 // ends in String::kHashShift 0s. Then we shift it so it is a multiple | 340 // ends in String::kHashShift 0s. Then we shift it so it is a multiple |
379 // of sizeof(Entry). This makes it easier to avoid making mistakes | 341 // of sizeof(Entry). This makes it easier to avoid making mistakes |
380 // in the hashed offset computations. | 342 // in the hashed offset computations. |
381 static Entry* entry(Entry* table, int offset) { | 343 static Entry* entry(Entry* table, int offset) { |
382 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift; | 344 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift; |
383 return reinterpret_cast<Entry*>( | 345 return reinterpret_cast<Entry*>( |
384 reinterpret_cast<Address>(table) + (offset << shift_amount)); | 346 reinterpret_cast<Address>(table) + (offset << shift_amount)); |
385 } | 347 } |
386 | 348 |
| 349 static const int kPrimaryTableSize = 2048; |
| 350 static const int kSecondaryTableSize = 512; |
| 351 |
| 352 Entry primary_[kPrimaryTableSize]; |
| 353 Entry secondary_[kSecondaryTableSize]; |
387 Isolate* isolate_; | 354 Isolate* isolate_; |
388 | 355 |
| 356 friend class Isolate; |
| 357 friend class SCTableReference; |
| 358 |
389 DISALLOW_COPY_AND_ASSIGN(StubCache); | 359 DISALLOW_COPY_AND_ASSIGN(StubCache); |
390 }; | 360 }; |
391 | 361 |
392 | 362 |
393 // ------------------------------------------------------------------------ | 363 // ------------------------------------------------------------------------ |
394 | 364 |
395 | 365 |
396 // Support functions for IC stubs for callbacks. | 366 // Support functions for IC stubs for callbacks. |
397 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty); | 367 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty); |
398 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty); | 368 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty); |
399 | 369 |
400 | 370 |
401 // Support functions for IC stubs for interceptors. | 371 // Support functions for IC stubs for interceptors. |
402 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly); | 372 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly); |
403 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); | 373 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); |
404 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); | 374 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); |
405 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); | 375 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); |
406 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty); | 376 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty); |
407 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); | 377 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); |
408 | 378 |
409 | 379 |
410 // The stub compiler compiles stubs for the stub cache. | 380 // The stub compilers compile stubs for the stub cache. |
411 class StubCompiler BASE_EMBEDDED { | 381 class StubCompiler BASE_EMBEDDED { |
412 public: | 382 public: |
413 StubCompiler() | 383 explicit StubCompiler(Isolate* isolate) |
414 : scope_(), masm_(Isolate::Current(), NULL, 256), failure_(NULL) { } | 384 : isolate_(isolate), masm_(isolate, NULL, 256), failure_(NULL) { } |
415 | 385 |
416 MUST_USE_RESULT MaybeObject* CompileCallInitialize(Code::Flags flags); | 386 // Functions to compile either CallIC or KeyedCallIC. The specific kind |
417 MUST_USE_RESULT MaybeObject* CompileCallPreMonomorphic(Code::Flags flags); | 387 // is extracted from the code flags. |
418 MUST_USE_RESULT MaybeObject* CompileCallNormal(Code::Flags flags); | 388 Handle<Code> CompileCallInitialize(Code::Flags flags); |
419 MUST_USE_RESULT MaybeObject* CompileCallMegamorphic(Code::Flags flags); | 389 Handle<Code> CompileCallPreMonomorphic(Code::Flags flags); |
420 MUST_USE_RESULT MaybeObject* CompileCallArguments(Code::Flags flags); | 390 Handle<Code> CompileCallNormal(Code::Flags flags); |
421 MUST_USE_RESULT MaybeObject* CompileCallMiss(Code::Flags flags); | 391 Handle<Code> CompileCallMegamorphic(Code::Flags flags); |
| 392 Handle<Code> CompileCallArguments(Code::Flags flags); |
| 393 Handle<Code> CompileCallMiss(Code::Flags flags); |
| 394 |
| 395 MUST_USE_RESULT MaybeObject* TryCompileCallMiss(Code::Flags flags); |
| 396 |
422 #ifdef ENABLE_DEBUGGER_SUPPORT | 397 #ifdef ENABLE_DEBUGGER_SUPPORT |
423 MUST_USE_RESULT MaybeObject* CompileCallDebugBreak(Code::Flags flags); | 398 Handle<Code> CompileCallDebugBreak(Code::Flags flags); |
424 MUST_USE_RESULT MaybeObject* CompileCallDebugPrepareStepIn(Code::Flags flags); | 399 Handle<Code> CompileCallDebugPrepareStepIn(Code::Flags flags); |
425 #endif | 400 #endif |
426 | 401 |
427 // Static functions for generating parts of stubs. | 402 // Static functions for generating parts of stubs. |
428 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, | 403 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, |
429 int index, | 404 int index, |
430 Register prototype); | 405 Register prototype); |
431 | 406 |
432 // Generates prototype loading code that uses the objects from the | 407 // Generates prototype loading code that uses the objects from the |
433 // context we were in when this function was called. If the context | 408 // context we were in when this function was called. If the context |
434 // has changed, a jump to miss is performed. This ties the generated | 409 // has changed, a jump to miss is performed. This ties the generated |
435 // code to a particular context and so must not be used in cases | 410 // code to a particular context and so must not be used in cases |
436 // where the generated code is not allowed to have references to | 411 // where the generated code is not allowed to have references to |
437 // objects from a context. | 412 // objects from a context. |
438 static void GenerateDirectLoadGlobalFunctionPrototype(MacroAssembler* masm, | 413 static void GenerateDirectLoadGlobalFunctionPrototype(MacroAssembler* masm, |
439 int index, | 414 int index, |
440 Register prototype, | 415 Register prototype, |
441 Label* miss); | 416 Label* miss); |
442 | 417 |
443 static void GenerateFastPropertyLoad(MacroAssembler* masm, | 418 static void GenerateFastPropertyLoad(MacroAssembler* masm, |
444 Register dst, Register src, | 419 Register dst, |
445 JSObject* holder, int index); | 420 Register src, |
| 421 Handle<JSObject> holder, |
| 422 int index); |
446 | 423 |
447 static void GenerateLoadArrayLength(MacroAssembler* masm, | 424 static void GenerateLoadArrayLength(MacroAssembler* masm, |
448 Register receiver, | 425 Register receiver, |
449 Register scratch, | 426 Register scratch, |
450 Label* miss_label); | 427 Label* miss_label); |
451 | 428 |
452 static void GenerateLoadStringLength(MacroAssembler* masm, | 429 static void GenerateLoadStringLength(MacroAssembler* masm, |
453 Register receiver, | 430 Register receiver, |
454 Register scratch1, | 431 Register scratch1, |
455 Register scratch2, | 432 Register scratch2, |
456 Label* miss_label, | 433 Label* miss_label, |
457 bool support_wrappers); | 434 bool support_wrappers); |
458 | 435 |
459 static void GenerateLoadFunctionPrototype(MacroAssembler* masm, | 436 static void GenerateLoadFunctionPrototype(MacroAssembler* masm, |
460 Register receiver, | 437 Register receiver, |
461 Register scratch1, | 438 Register scratch1, |
462 Register scratch2, | 439 Register scratch2, |
463 Label* miss_label); | 440 Label* miss_label); |
464 | 441 |
465 static void GenerateStoreField(MacroAssembler* masm, | 442 static void GenerateStoreField(MacroAssembler* masm, |
466 JSObject* object, | 443 Handle<JSObject> object, |
467 int index, | 444 int index, |
468 Map* transition, | 445 Handle<Map> transition, |
469 Register receiver_reg, | 446 Register receiver_reg, |
470 Register name_reg, | 447 Register name_reg, |
471 Register scratch, | 448 Register scratch, |
472 Label* miss_label); | 449 Label* miss_label); |
473 | 450 |
474 static void GenerateLoadMiss(MacroAssembler* masm, | 451 static void GenerateLoadMiss(MacroAssembler* masm, |
475 Code::Kind kind); | 452 Code::Kind kind); |
476 | 453 |
477 static void GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm); | 454 static void GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm); |
478 | 455 |
479 // Generates code that verifies that the property holder has not changed | 456 // Generates code that verifies that the property holder has not changed |
480 // (checking maps of objects in the prototype chain for fast and global | 457 // (checking maps of objects in the prototype chain for fast and global |
481 // objects or doing negative lookup for slow objects, ensures that the | 458 // objects or doing negative lookup for slow objects, ensures that the |
482 // property cells for global objects are still empty) and checks that the map | 459 // property cells for global objects are still empty) and checks that the map |
483 // of the holder has not changed. If necessary the function also generates | 460 // of the holder has not changed. If necessary the function also generates |
484 // code for security check in case of global object holders. Helps to make | 461 // code for security check in case of global object holders. Helps to make |
485 // sure that the current IC is still valid. | 462 // sure that the current IC is still valid. |
486 // | 463 // |
487 // The scratch and holder registers are always clobbered, but the object | 464 // The scratch and holder registers are always clobbered, but the object |
488 // register is only clobbered if it the same as the holder register. The | 465 // register is only clobbered if it the same as the holder register. The |
489 // function returns a register containing the holder - either object_reg or | 466 // function returns a register containing the holder - either object_reg or |
490 // holder_reg. | 467 // holder_reg. |
491 // The function can optionally (when save_at_depth != | 468 // The function can optionally (when save_at_depth != |
492 // kInvalidProtoDepth) save the object at the given depth by moving | 469 // kInvalidProtoDepth) save the object at the given depth by moving |
493 // it to [esp + kPointerSize]. | 470 // it to [esp + kPointerSize]. |
| 471 Register CheckPrototypes(Handle<JSObject> object, |
| 472 Register object_reg, |
| 473 Handle<JSObject> holder, |
| 474 Register holder_reg, |
| 475 Register scratch1, |
| 476 Register scratch2, |
| 477 Handle<String> name, |
| 478 Label* miss) { |
| 479 return CheckPrototypes(object, object_reg, holder, holder_reg, scratch1, |
| 480 scratch2, name, kInvalidProtoDepth, miss); |
| 481 } |
494 | 482 |
| 483 Register CheckPrototypes(Handle<JSObject> object, |
| 484 Register object_reg, |
| 485 Handle<JSObject> holder, |
| 486 Register holder_reg, |
| 487 Register scratch1, |
| 488 Register scratch2, |
| 489 Handle<String> name, |
| 490 int save_at_depth, |
| 491 Label* miss); |
| 492 |
| 493 // TODO(kmillikin): Eliminate this function when the stub cache is fully |
| 494 // handlified. |
495 Register CheckPrototypes(JSObject* object, | 495 Register CheckPrototypes(JSObject* object, |
496 Register object_reg, | 496 Register object_reg, |
497 JSObject* holder, | 497 JSObject* holder, |
498 Register holder_reg, | 498 Register holder_reg, |
499 Register scratch1, | 499 Register scratch1, |
500 Register scratch2, | 500 Register scratch2, |
501 String* name, | 501 String* name, |
502 Label* miss) { | 502 Label* miss) { |
503 return CheckPrototypes(object, object_reg, holder, holder_reg, scratch1, | 503 return CheckPrototypes(object, object_reg, holder, holder_reg, scratch1, |
504 scratch2, name, kInvalidProtoDepth, miss); | 504 scratch2, name, kInvalidProtoDepth, miss); |
505 } | 505 } |
506 | 506 |
| 507 // TODO(kmillikin): Eliminate this function when the stub cache is fully |
| 508 // handlified. |
507 Register CheckPrototypes(JSObject* object, | 509 Register CheckPrototypes(JSObject* object, |
508 Register object_reg, | 510 Register object_reg, |
509 JSObject* holder, | 511 JSObject* holder, |
510 Register holder_reg, | 512 Register holder_reg, |
511 Register scratch1, | 513 Register scratch1, |
512 Register scratch2, | 514 Register scratch2, |
513 String* name, | 515 String* name, |
514 int save_at_depth, | 516 int save_at_depth, |
515 Label* miss); | 517 Label* miss); |
516 | 518 |
517 protected: | 519 protected: |
518 MaybeObject* GetCodeWithFlags(Code::Flags flags, const char* name); | 520 Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); |
519 MaybeObject* GetCodeWithFlags(Code::Flags flags, String* name); | 521 Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<String> name); |
| 522 |
| 523 MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags, |
| 524 const char* name); |
| 525 MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags, |
| 526 String* name); |
520 | 527 |
521 MacroAssembler* masm() { return &masm_; } | 528 MacroAssembler* masm() { return &masm_; } |
522 void set_failure(Failure* failure) { failure_ = failure; } | 529 void set_failure(Failure* failure) { failure_ = failure; } |
523 | 530 |
524 void GenerateLoadField(JSObject* object, | 531 void GenerateLoadField(Handle<JSObject> object, |
525 JSObject* holder, | 532 Handle<JSObject> holder, |
526 Register receiver, | 533 Register receiver, |
527 Register scratch1, | 534 Register scratch1, |
528 Register scratch2, | 535 Register scratch2, |
529 Register scratch3, | 536 Register scratch3, |
530 int index, | 537 int index, |
531 String* name, | 538 Handle<String> name, |
532 Label* miss); | 539 Label* miss); |
533 | 540 |
534 MaybeObject* GenerateLoadCallback(JSObject* object, | 541 MaybeObject* GenerateLoadCallback(JSObject* object, |
535 JSObject* holder, | 542 JSObject* holder, |
536 Register receiver, | 543 Register receiver, |
537 Register name_reg, | 544 Register name_reg, |
538 Register scratch1, | 545 Register scratch1, |
539 Register scratch2, | 546 Register scratch2, |
540 Register scratch3, | 547 Register scratch3, |
541 AccessorInfo* callback, | 548 AccessorInfo* callback, |
542 String* name, | 549 String* name, |
543 Label* miss); | 550 Label* miss); |
544 | 551 |
545 void GenerateLoadConstant(JSObject* object, | 552 void GenerateLoadConstant(Handle<JSObject> object, |
546 JSObject* holder, | 553 Handle<JSObject> holder, |
547 Register receiver, | 554 Register receiver, |
548 Register scratch1, | 555 Register scratch1, |
549 Register scratch2, | 556 Register scratch2, |
550 Register scratch3, | 557 Register scratch3, |
551 Object* value, | 558 Handle<Object> value, |
552 String* name, | 559 Handle<String> name, |
553 Label* miss); | 560 Label* miss); |
554 | 561 |
555 void GenerateLoadInterceptor(JSObject* object, | 562 void GenerateLoadInterceptor(JSObject* object, |
556 JSObject* holder, | 563 JSObject* holder, |
557 LookupResult* lookup, | 564 LookupResult* lookup, |
558 Register receiver, | 565 Register receiver, |
559 Register name_reg, | 566 Register name_reg, |
560 Register scratch1, | 567 Register scratch1, |
561 Register scratch2, | 568 Register scratch2, |
562 Register scratch3, | 569 Register scratch3, |
563 String* name, | 570 String* name, |
564 Label* miss); | 571 Label* miss); |
565 | 572 |
566 static void LookupPostInterceptor(JSObject* holder, | 573 static void LookupPostInterceptor(JSObject* holder, |
567 String* name, | 574 String* name, |
568 LookupResult* lookup); | 575 LookupResult* lookup); |
569 | 576 |
570 Isolate* isolate() { return scope_.isolate(); } | 577 Isolate* isolate() { return isolate_; } |
571 Heap* heap() { return isolate()->heap(); } | 578 Heap* heap() { return isolate()->heap(); } |
572 Factory* factory() { return isolate()->factory(); } | 579 Factory* factory() { return isolate()->factory(); } |
573 | 580 |
574 private: | 581 private: |
575 HandleScope scope_; | 582 Isolate* isolate_; |
576 MacroAssembler masm_; | 583 MacroAssembler masm_; |
577 Failure* failure_; | 584 Failure* failure_; |
578 }; | 585 }; |
579 | 586 |
580 | 587 |
581 class LoadStubCompiler: public StubCompiler { | 588 class LoadStubCompiler: public StubCompiler { |
582 public: | 589 public: |
583 MUST_USE_RESULT MaybeObject* CompileLoadNonexistent(String* name, | 590 explicit LoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
584 JSObject* object, | |
585 JSObject* last); | |
586 | 591 |
587 MUST_USE_RESULT MaybeObject* CompileLoadField(JSObject* object, | 592 Handle<Code> CompileLoadNonexistent(Handle<String> name, |
588 JSObject* holder, | 593 Handle<JSObject> object, |
589 int index, | 594 Handle<JSObject> last); |
590 String* name); | 595 |
| 596 Handle<Code> CompileLoadField(Handle<JSObject> object, |
| 597 Handle<JSObject> holder, |
| 598 int index, |
| 599 Handle<String> name); |
| 600 |
| 601 Handle<Code> CompileLoadCallback(Handle<String> name, |
| 602 Handle<JSObject> object, |
| 603 Handle<JSObject> holder, |
| 604 Handle<AccessorInfo> callback); |
591 | 605 |
592 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, | 606 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, |
593 JSObject* object, | 607 JSObject* object, |
594 JSObject* holder, | 608 JSObject* holder, |
595 AccessorInfo* callback); | 609 AccessorInfo* callback); |
596 | 610 |
597 MUST_USE_RESULT MaybeObject* CompileLoadConstant(JSObject* object, | 611 Handle<Code> CompileLoadConstant(Handle<JSObject> object, |
598 JSObject* holder, | 612 Handle<JSObject> holder, |
599 Object* value, | 613 Handle<Object> value, |
600 String* name); | 614 Handle<String> name); |
| 615 |
| 616 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
| 617 Handle<JSObject> holder, |
| 618 Handle<String> name); |
601 | 619 |
602 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, | 620 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, |
603 JSObject* holder, | 621 JSObject* holder, |
604 String* name); | 622 String* name); |
605 | 623 |
606 MUST_USE_RESULT MaybeObject* CompileLoadGlobal(JSObject* object, | 624 Handle<Code> CompileLoadGlobal(Handle<JSObject> object, |
607 GlobalObject* holder, | 625 Handle<GlobalObject> holder, |
608 JSGlobalPropertyCell* cell, | 626 Handle<JSGlobalPropertyCell> cell, |
609 String* name, | 627 Handle<String> name, |
610 bool is_dont_delete); | 628 bool is_dont_delete); |
611 | 629 |
612 private: | 630 private: |
613 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name); | 631 MUST_USE_RESULT MaybeObject* TryGetCode(PropertyType type, String* name); |
| 632 |
| 633 Handle<Code> GetCode(PropertyType type, Handle<String> name); |
614 }; | 634 }; |
615 | 635 |
616 | 636 |
617 class KeyedLoadStubCompiler: public StubCompiler { | 637 class KeyedLoadStubCompiler: public StubCompiler { |
618 public: | 638 public: |
619 MUST_USE_RESULT MaybeObject* CompileLoadField(String* name, | 639 explicit KeyedLoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
620 JSObject* object, | 640 |
621 JSObject* holder, | 641 Handle<Code> CompileLoadField(Handle<String> name, |
622 int index); | 642 Handle<JSObject> object, |
| 643 Handle<JSObject> holder, |
| 644 int index); |
| 645 |
| 646 Handle<Code> CompileLoadCallback(Handle<String> name, |
| 647 Handle<JSObject> object, |
| 648 Handle<JSObject> holder, |
| 649 Handle<AccessorInfo> callback); |
623 | 650 |
624 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, | 651 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, |
625 JSObject* object, | 652 JSObject* object, |
626 JSObject* holder, | 653 JSObject* holder, |
627 AccessorInfo* callback); | 654 AccessorInfo* callback); |
628 | 655 |
629 MUST_USE_RESULT MaybeObject* CompileLoadConstant(String* name, | 656 Handle<Code> CompileLoadConstant(Handle<String> name, |
630 JSObject* object, | 657 Handle<JSObject> object, |
631 JSObject* holder, | 658 Handle<JSObject> holder, |
632 Object* value); | 659 Handle<Object> value); |
| 660 |
| 661 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
| 662 Handle<JSObject> holder, |
| 663 Handle<String> name); |
633 | 664 |
634 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, | 665 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, |
635 JSObject* holder, | 666 JSObject* holder, |
636 String* name); | 667 String* name); |
637 | 668 |
638 MUST_USE_RESULT MaybeObject* CompileLoadArrayLength(String* name); | 669 Handle<Code> CompileLoadArrayLength(Handle<String> name); |
639 MUST_USE_RESULT MaybeObject* CompileLoadStringLength(String* name); | |
640 MUST_USE_RESULT MaybeObject* CompileLoadFunctionPrototype(String* name); | |
641 | 670 |
642 MUST_USE_RESULT MaybeObject* CompileLoadElement(Map* receiver_map); | 671 Handle<Code> CompileLoadStringLength(Handle<String> name); |
643 | 672 |
644 MUST_USE_RESULT MaybeObject* CompileLoadPolymorphic( | 673 Handle<Code> CompileLoadFunctionPrototype(Handle<String> name); |
645 MapList* receiver_maps, | 674 |
646 CodeList* handler_ics); | 675 Handle<Code> CompileLoadElement(Handle<Map> receiver_map); |
| 676 |
| 677 Handle<Code> CompileLoadPolymorphic(MapHandleList* receiver_maps, |
| 678 CodeHandleList* handler_ics); |
647 | 679 |
648 static void GenerateLoadExternalArray(MacroAssembler* masm, | 680 static void GenerateLoadExternalArray(MacroAssembler* masm, |
649 ElementsKind elements_kind); | 681 ElementsKind elements_kind); |
650 | 682 |
651 static void GenerateLoadFastElement(MacroAssembler* masm); | 683 static void GenerateLoadFastElement(MacroAssembler* masm); |
652 | 684 |
653 static void GenerateLoadFastDoubleElement(MacroAssembler* masm); | 685 static void GenerateLoadFastDoubleElement(MacroAssembler* masm); |
654 | 686 |
655 static void GenerateLoadDictionaryElement(MacroAssembler* masm); | 687 static void GenerateLoadDictionaryElement(MacroAssembler* masm); |
656 | 688 |
657 private: | 689 private: |
658 MaybeObject* GetCode(PropertyType type, | 690 MaybeObject* TryGetCode(PropertyType type, |
659 String* name, | 691 String* name, |
| 692 InlineCacheState state = MONOMORPHIC); |
| 693 |
| 694 Handle<Code> GetCode(PropertyType type, |
| 695 Handle<String> name, |
660 InlineCacheState state = MONOMORPHIC); | 696 InlineCacheState state = MONOMORPHIC); |
661 }; | 697 }; |
662 | 698 |
663 | 699 |
664 class StoreStubCompiler: public StubCompiler { | 700 class StoreStubCompiler: public StubCompiler { |
665 public: | 701 public: |
666 explicit StoreStubCompiler(StrictModeFlag strict_mode) | 702 StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode) |
667 : strict_mode_(strict_mode) { } | 703 : StubCompiler(isolate), strict_mode_(strict_mode) { } |
668 | |
669 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, | |
670 int index, | |
671 Map* transition, | |
672 String* name); | |
673 | |
674 MUST_USE_RESULT MaybeObject* CompileStoreCallback(JSObject* object, | |
675 AccessorInfo* callbacks, | |
676 String* name); | |
677 MUST_USE_RESULT MaybeObject* CompileStoreInterceptor(JSObject* object, | |
678 String* name); | |
679 MUST_USE_RESULT MaybeObject* CompileStoreGlobal(GlobalObject* object, | |
680 JSGlobalPropertyCell* holder, | |
681 String* name); | |
682 | 704 |
683 | 705 |
| 706 Handle<Code> CompileStoreField(Handle<JSObject> object, |
| 707 int index, |
| 708 Handle<Map> transition, |
| 709 Handle<String> name); |
| 710 |
| 711 Handle<Code> CompileStoreCallback(Handle<JSObject> object, |
| 712 Handle<AccessorInfo> callback, |
| 713 Handle<String> name); |
| 714 |
| 715 Handle<Code> CompileStoreInterceptor(Handle<JSObject> object, |
| 716 Handle<String> name); |
| 717 |
| 718 Handle<Code> CompileStoreGlobal(Handle<GlobalObject> object, |
| 719 Handle<JSGlobalPropertyCell> holder, |
| 720 Handle<String> name); |
| 721 |
684 private: | 722 private: |
685 MaybeObject* GetCode(PropertyType type, String* name); | 723 Handle<Code> GetCode(PropertyType type, Handle<String> name); |
686 | 724 |
687 StrictModeFlag strict_mode_; | 725 StrictModeFlag strict_mode_; |
688 }; | 726 }; |
689 | 727 |
690 | 728 |
691 class KeyedStoreStubCompiler: public StubCompiler { | 729 class KeyedStoreStubCompiler: public StubCompiler { |
692 public: | 730 public: |
693 explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) | 731 KeyedStoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode) |
694 : strict_mode_(strict_mode) { } | 732 : StubCompiler(isolate), strict_mode_(strict_mode) { } |
695 | 733 |
696 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, | 734 Handle<Code> CompileStoreField(Handle<JSObject> object, |
697 int index, | 735 int index, |
698 Map* transition, | 736 Handle<Map> transition, |
699 String* name); | 737 Handle<String> name); |
700 | 738 |
701 MUST_USE_RESULT MaybeObject* CompileStoreElement(Map* receiver_map); | 739 Handle<Code> CompileStoreElement(Handle<Map> receiver_map); |
702 | 740 |
703 MUST_USE_RESULT MaybeObject* CompileStorePolymorphic( | 741 Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps, |
704 MapList* receiver_maps, | 742 CodeHandleList* handler_stubs, |
705 CodeList* handler_stubs, | 743 MapHandleList* transitioned_maps); |
706 MapList* transitioned_maps); | |
707 | 744 |
708 static void GenerateStoreFastElement(MacroAssembler* masm, | 745 static void GenerateStoreFastElement(MacroAssembler* masm, |
709 bool is_js_array, | 746 bool is_js_array, |
710 ElementsKind element_kind); | 747 ElementsKind element_kind); |
711 | 748 |
712 static void GenerateStoreFastDoubleElement(MacroAssembler* masm, | 749 static void GenerateStoreFastDoubleElement(MacroAssembler* masm, |
713 bool is_js_array); | 750 bool is_js_array); |
714 | 751 |
715 static void GenerateStoreExternalArray(MacroAssembler* masm, | 752 static void GenerateStoreExternalArray(MacroAssembler* masm, |
716 ElementsKind elements_kind); | 753 ElementsKind elements_kind); |
717 | 754 |
718 static void GenerateStoreDictionaryElement(MacroAssembler* masm); | 755 static void GenerateStoreDictionaryElement(MacroAssembler* masm); |
719 | 756 |
720 private: | 757 private: |
721 MaybeObject* GetCode(PropertyType type, | 758 Handle<Code> GetCode(PropertyType type, |
722 String* name, | 759 Handle<String> name, |
723 InlineCacheState state = MONOMORPHIC); | 760 InlineCacheState state = MONOMORPHIC); |
724 | 761 |
725 StrictModeFlag strict_mode_; | 762 StrictModeFlag strict_mode_; |
726 }; | 763 }; |
727 | 764 |
728 | 765 |
729 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call | 766 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call |
730 // IC stubs. | 767 // IC stubs. |
731 #define CUSTOM_CALL_IC_GENERATORS(V) \ | 768 #define CUSTOM_CALL_IC_GENERATORS(V) \ |
732 V(ArrayPush) \ | 769 V(ArrayPush) \ |
733 V(ArrayPop) \ | 770 V(ArrayPop) \ |
734 V(StringCharCodeAt) \ | 771 V(StringCharCodeAt) \ |
735 V(StringCharAt) \ | 772 V(StringCharAt) \ |
736 V(StringFromCharCode) \ | 773 V(StringFromCharCode) \ |
737 V(MathFloor) \ | 774 V(MathFloor) \ |
738 V(MathAbs) | 775 V(MathAbs) |
739 | 776 |
740 | 777 |
741 class CallOptimization; | 778 class CallOptimization; |
742 | 779 |
743 class CallStubCompiler: public StubCompiler { | 780 class CallStubCompiler: public StubCompiler { |
744 public: | 781 public: |
745 CallStubCompiler(int argc, | 782 CallStubCompiler(Isolate* isolate, |
| 783 int argc, |
746 Code::Kind kind, | 784 Code::Kind kind, |
747 Code::ExtraICState extra_ic_state, | 785 Code::ExtraICState extra_state, |
748 InlineCacheHolderFlag cache_holder); | 786 InlineCacheHolderFlag cache_holder); |
749 | 787 |
750 MUST_USE_RESULT MaybeObject* CompileCallField( | 788 Handle<Code> CompileCallField(Handle<JSObject> object, |
751 JSObject* object, | 789 Handle<JSObject> holder, |
752 JSObject* holder, | 790 int index, |
753 int index, | 791 Handle<String> name); |
754 String* name); | |
755 | 792 |
756 MUST_USE_RESULT MaybeObject* CompileCallConstant( | 793 Handle<Code> CompileCallConstant(Handle<Object> object, |
757 Object* object, | 794 Handle<JSObject> holder, |
758 JSObject* holder, | 795 Handle<JSFunction> function, |
759 JSFunction* function, | 796 Handle<String> name, |
760 String* name, | 797 CheckType check); |
761 CheckType check); | |
762 | 798 |
763 MUST_USE_RESULT MaybeObject* CompileCallInterceptor( | 799 MUST_USE_RESULT MaybeObject* CompileCallConstant(Object* object, |
764 JSObject* object, | 800 JSObject* holder, |
765 JSObject* holder, | 801 JSFunction* function, |
766 String* name); | 802 String* name, |
| 803 CheckType check); |
767 | 804 |
768 MUST_USE_RESULT MaybeObject* CompileCallGlobal( | 805 Handle<Code> CompileCallInterceptor(Handle<JSObject> object, |
769 JSObject* object, | 806 Handle<JSObject> holder, |
770 GlobalObject* holder, | 807 Handle<String> name); |
771 JSGlobalPropertyCell* cell, | 808 |
772 JSFunction* function, | 809 MUST_USE_RESULT MaybeObject* CompileCallInterceptor(JSObject* object, |
773 String* name); | 810 JSObject* holder, |
| 811 String* name); |
| 812 |
| 813 Handle<Code> CompileCallGlobal(Handle<JSObject> object, |
| 814 Handle<GlobalObject> holder, |
| 815 Handle<JSGlobalPropertyCell> cell, |
| 816 Handle<JSFunction> function, |
| 817 Handle<String> name); |
| 818 |
| 819 MUST_USE_RESULT MaybeObject* CompileCallGlobal(JSObject* object, |
| 820 GlobalObject* holder, |
| 821 JSGlobalPropertyCell* cell, |
| 822 JSFunction* function, |
| 823 String* name); |
774 | 824 |
775 static bool HasCustomCallGenerator(JSFunction* function); | 825 static bool HasCustomCallGenerator(JSFunction* function); |
776 | 826 |
777 private: | 827 private: |
778 // Compiles a custom call constant/global IC. For constant calls | 828 // Compiles a custom call constant/global IC. For constant calls |
779 // cell is NULL. Returns undefined if there is no custom call code | 829 // cell is NULL. Returns undefined if there is no custom call code |
780 // for the given function or it can't be generated. | 830 // for the given function or it can't be generated. |
781 MUST_USE_RESULT MaybeObject* CompileCustomCall(Object* object, | 831 MUST_USE_RESULT MaybeObject* CompileCustomCall(Object* object, |
782 JSObject* holder, | 832 JSObject* holder, |
783 JSGlobalPropertyCell* cell, | 833 JSGlobalPropertyCell* cell, |
(...skipping 12 matching lines...) Expand all Loading... |
796 MUST_USE_RESULT MaybeObject* CompileFastApiCall( | 846 MUST_USE_RESULT MaybeObject* CompileFastApiCall( |
797 const CallOptimization& optimization, | 847 const CallOptimization& optimization, |
798 Object* object, | 848 Object* object, |
799 JSObject* holder, | 849 JSObject* holder, |
800 JSGlobalPropertyCell* cell, | 850 JSGlobalPropertyCell* cell, |
801 JSFunction* function, | 851 JSFunction* function, |
802 String* name); | 852 String* name); |
803 | 853 |
804 const ParameterCount arguments_; | 854 const ParameterCount arguments_; |
805 const Code::Kind kind_; | 855 const Code::Kind kind_; |
806 const Code::ExtraICState extra_ic_state_; | 856 const Code::ExtraICState extra_state_; |
807 const InlineCacheHolderFlag cache_holder_; | 857 const InlineCacheHolderFlag cache_holder_; |
808 | 858 |
809 const ParameterCount& arguments() { return arguments_; } | 859 const ParameterCount& arguments() { return arguments_; } |
810 | 860 |
811 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name); | 861 Handle<Code> GetCode(PropertyType type, Handle<String> name); |
| 862 Handle<Code> GetCode(Handle<JSFunction> function); |
812 | 863 |
813 // Convenience function. Calls GetCode above passing | 864 // TODO(kmillikin): Eliminate these functions when the stub cache is fully |
814 // CONSTANT_FUNCTION type and the name of the given function. | 865 // handlified. |
815 MUST_USE_RESULT MaybeObject* GetCode(JSFunction* function); | 866 MUST_USE_RESULT MaybeObject* TryGetCode(PropertyType type, String* name); |
| 867 MUST_USE_RESULT MaybeObject* TryGetCode(JSFunction* function); |
816 | 868 |
817 void GenerateNameCheck(String* name, Label* miss); | 869 void GenerateNameCheck(Handle<String> name, Label* miss); |
818 | 870 |
819 void GenerateGlobalReceiverCheck(JSObject* object, | 871 void GenerateGlobalReceiverCheck(JSObject* object, |
820 JSObject* holder, | 872 JSObject* holder, |
821 String* name, | 873 String* name, |
822 Label* miss); | 874 Label* miss); |
823 | 875 |
824 // Generates code to load the function from the cell checking that | 876 // Generates code to load the function from the cell checking that |
825 // it still contains the same function. | 877 // it still contains the same function. |
826 void GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell, | 878 void GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell, |
827 JSFunction* function, | 879 JSFunction* function, |
828 Label* miss); | 880 Label* miss); |
829 | 881 |
830 // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot | 882 // Generates a jump to CallIC miss stub. |
831 // be generated. | 883 void GenerateMissBranch(); |
832 MUST_USE_RESULT MaybeObject* GenerateMissBranch(); | 884 |
| 885 // TODO(kmillikin): Eliminate this function when the stub cache is fully |
| 886 // handlified. |
| 887 MUST_USE_RESULT MaybeObject* TryGenerateMissBranch(); |
833 }; | 888 }; |
834 | 889 |
835 | 890 |
836 class ConstructStubCompiler: public StubCompiler { | 891 class ConstructStubCompiler: public StubCompiler { |
837 public: | 892 public: |
838 explicit ConstructStubCompiler() {} | 893 explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
839 | 894 |
840 MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function); | 895 MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function); |
841 | 896 |
842 private: | 897 private: |
843 MaybeObject* GetCode(); | 898 MaybeObject* GetCode(); |
844 }; | 899 }; |
845 | 900 |
846 | 901 |
847 // Holds information about possible function call optimizations. | 902 // Holds information about possible function call optimizations. |
848 class CallOptimization BASE_EMBEDDED { | 903 class CallOptimization BASE_EMBEDDED { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 JSFunction* constant_function_; | 944 JSFunction* constant_function_; |
890 bool is_simple_api_call_; | 945 bool is_simple_api_call_; |
891 FunctionTemplateInfo* expected_receiver_type_; | 946 FunctionTemplateInfo* expected_receiver_type_; |
892 CallHandlerInfo* api_call_info_; | 947 CallHandlerInfo* api_call_info_; |
893 }; | 948 }; |
894 | 949 |
895 | 950 |
896 } } // namespace v8::internal | 951 } } // namespace v8::internal |
897 | 952 |
898 #endif // V8_STUB_CACHE_H_ | 953 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |