OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
7 | 7 |
| 8 #include <functional> |
| 9 |
8 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
9 #include "src/objects.h" | 11 #include "src/objects.h" |
10 | 12 |
11 namespace v8 { | 13 namespace v8 { |
12 namespace internal { | 14 namespace internal { |
13 | 15 |
14 class CallInterfaceDescriptor; | 16 class CallInterfaceDescriptor; |
15 class StatsCounter; | 17 class StatsCounter; |
16 class StubCache; | 18 class StubCache; |
17 | 19 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return BitFieldDecode(word32, T::kShift, T::kMask); | 265 return BitFieldDecode(word32, T::kShift, T::kMask); |
264 } | 266 } |
265 | 267 |
266 compiler::Node* BitFieldDecode(compiler::Node* word32, uint32_t shift, | 268 compiler::Node* BitFieldDecode(compiler::Node* word32, uint32_t shift, |
267 uint32_t mask); | 269 uint32_t mask); |
268 | 270 |
269 void SetCounter(StatsCounter* counter, int value); | 271 void SetCounter(StatsCounter* counter, int value); |
270 void IncrementCounter(StatsCounter* counter, int delta); | 272 void IncrementCounter(StatsCounter* counter, int delta); |
271 void DecrementCounter(StatsCounter* counter, int delta); | 273 void DecrementCounter(StatsCounter* counter, int delta); |
272 | 274 |
| 275 // Generates "if (false) goto label" code. Useful for marking a label as |
| 276 // "live" to avoid assertion failures during graph building. In the resulting |
| 277 // code this check will be eliminated. |
| 278 void Use(Label* label); |
| 279 |
273 // Various building blocks for stubs doing property lookups. | 280 // Various building blocks for stubs doing property lookups. |
274 void TryToName(compiler::Node* key, Label* if_keyisindex, Variable* var_index, | 281 void TryToName(compiler::Node* key, Label* if_keyisindex, Variable* var_index, |
275 Label* if_keyisunique, Label* if_bailout); | 282 Label* if_keyisunique, Label* if_bailout); |
276 | 283 |
277 // Calculates array index for given dictionary entry and entry field. | 284 // Calculates array index for given dictionary entry and entry field. |
278 // See Dictionary::EntryToIndex(). | 285 // See Dictionary::EntryToIndex(). |
279 template <typename Dictionary> | 286 template <typename Dictionary> |
280 compiler::Node* EntryToIndex(compiler::Node* entry, int field_index); | 287 compiler::Node* EntryToIndex(compiler::Node* entry, int field_index); |
281 template <typename Dictionary> | 288 template <typename Dictionary> |
282 compiler::Node* EntryToIndex(compiler::Node* entry) { | 289 compiler::Node* EntryToIndex(compiler::Node* entry) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 compiler::Node* unique_name, Label* if_found_fast, | 356 compiler::Node* unique_name, Label* if_found_fast, |
350 Label* if_found_dict, Label* if_found_global, | 357 Label* if_found_dict, Label* if_found_global, |
351 Variable* var_meta_storage, Variable* var_name_index, | 358 Variable* var_meta_storage, Variable* var_name_index, |
352 Label* if_not_found, Label* if_bailout); | 359 Label* if_not_found, Label* if_bailout); |
353 | 360 |
354 void TryLookupElement(compiler::Node* object, compiler::Node* map, | 361 void TryLookupElement(compiler::Node* object, compiler::Node* map, |
355 compiler::Node* instance_type, compiler::Node* index, | 362 compiler::Node* instance_type, compiler::Node* index, |
356 Label* if_found, Label* if_not_found, | 363 Label* if_found, Label* if_not_found, |
357 Label* if_bailout); | 364 Label* if_bailout); |
358 | 365 |
| 366 // This is a type of a lookup in holder generator function. In case of a |
| 367 // property lookup the {key} is guaranteed to be a unique name and in case of |
| 368 // element lookup the key is an Int32 index. |
| 369 typedef std::function<void(compiler::Node* receiver, compiler::Node* holder, |
| 370 compiler::Node* map, compiler::Node* instance_type, |
| 371 compiler::Node* key, Label* next_holder, |
| 372 Label* if_bailout)> |
| 373 LookupInHolder; |
| 374 |
| 375 // Generic property prototype chain lookup generator. |
| 376 // For properties it generates lookup using given {lookup_property_in_holder} |
| 377 // and for elements it uses {lookup_element_in_holder}. |
| 378 // Upon reaching the end of prototype chain the control goes to {if_end}. |
| 379 // If it can't handle the case {receiver}/{key} case then the control goes |
| 380 // to {if_bailout}. |
| 381 void TryPrototypeChainLookup(compiler::Node* receiver, compiler::Node* key, |
| 382 LookupInHolder& lookup_property_in_holder, |
| 383 LookupInHolder& lookup_element_in_holder, |
| 384 Label* if_end, Label* if_bailout); |
| 385 |
359 // Instanceof helpers. | 386 // Instanceof helpers. |
360 // ES6 section 7.3.19 OrdinaryHasInstance (C, O) | 387 // ES6 section 7.3.19 OrdinaryHasInstance (C, O) |
361 compiler::Node* OrdinaryHasInstance(compiler::Node* context, | 388 compiler::Node* OrdinaryHasInstance(compiler::Node* context, |
362 compiler::Node* callable, | 389 compiler::Node* callable, |
363 compiler::Node* object); | 390 compiler::Node* object); |
364 | 391 |
365 // LoadIC helpers. | 392 // LoadIC helpers. |
366 struct LoadICParameters { | 393 struct LoadICParameters { |
367 LoadICParameters(compiler::Node* context, compiler::Node* receiver, | 394 LoadICParameters(compiler::Node* context, compiler::Node* receiver, |
368 compiler::Node* name, compiler::Node* slot, | 395 compiler::Node* name, compiler::Node* slot, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 AllocationFlags flags, | 462 AllocationFlags flags, |
436 compiler::Node* top_adddress, | 463 compiler::Node* top_adddress, |
437 compiler::Node* limit_address); | 464 compiler::Node* limit_address); |
438 | 465 |
439 static const int kElementLoopUnrollThreshold = 8; | 466 static const int kElementLoopUnrollThreshold = 8; |
440 }; | 467 }; |
441 | 468 |
442 } // namespace internal | 469 } // namespace internal |
443 } // namespace v8 | 470 } // namespace v8 |
444 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 471 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |