Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5350 // Bit field containing various information collected by the compiler to | 5350 // Bit field containing various information collected by the compiler to |
| 5351 // drive optimization. | 5351 // drive optimization. |
| 5352 inline int compiler_hints(); | 5352 inline int compiler_hints(); |
| 5353 inline void set_compiler_hints(int value); | 5353 inline void set_compiler_hints(int value); |
| 5354 | 5354 |
| 5355 inline int ast_node_count(); | 5355 inline int ast_node_count(); |
| 5356 inline void set_ast_node_count(int count); | 5356 inline void set_ast_node_count(int count); |
| 5357 | 5357 |
| 5358 // A counter used to determine when to stress the deoptimizer with a | 5358 // A counter used to determine when to stress the deoptimizer with a |
| 5359 // deopt. | 5359 // deopt. |
| 5360 inline int deopt_counter(); | 5360 inline int stress_deopt_counter(); |
| 5361 inline void set_deopt_counter(int counter); | 5361 inline void set_stress_deopt_counter(int counter); |
| 5362 | 5362 |
| 5363 inline int profiler_ticks(); | 5363 inline int profiler_ticks(); |
| 5364 | 5364 |
| 5365 // Inline cache age is used to infer whether the function survived a context | 5365 // Inline cache age is used to infer whether the function survived a context |
| 5366 // disposal or not. In the former case we reset the opt_count. | 5366 // disposal or not. In the former case we reset the opt_count. |
| 5367 inline int ic_age(); | 5367 inline int ic_age(); |
| 5368 inline void set_ic_age(int age); | 5368 inline void set_ic_age(int age); |
| 5369 | 5369 |
| 5370 // Add information on assignments of the form this.x = ...; | 5370 // Add information on assignments of the form this.x = ...; |
| 5371 void SetThisPropertyAssignmentsInfo( | 5371 void SetThisPropertyAssignmentsInfo( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5479 inline void set_this_property_assignments_count(int value); | 5479 inline void set_this_property_assignments_count(int value); |
| 5480 String* GetThisPropertyAssignmentName(int index); | 5480 String* GetThisPropertyAssignmentName(int index); |
| 5481 bool IsThisPropertyAssignmentArgument(int index); | 5481 bool IsThisPropertyAssignmentArgument(int index); |
| 5482 int GetThisPropertyAssignmentArgument(int index); | 5482 int GetThisPropertyAssignmentArgument(int index); |
| 5483 Object* GetThisPropertyAssignmentConstant(int index); | 5483 Object* GetThisPropertyAssignmentConstant(int index); |
| 5484 | 5484 |
| 5485 // [source code]: Source code for the function. | 5485 // [source code]: Source code for the function. |
| 5486 bool HasSourceCode(); | 5486 bool HasSourceCode(); |
| 5487 Handle<Object> GetSourceCode(); | 5487 Handle<Object> GetSourceCode(); |
| 5488 | 5488 |
| 5489 // Number of times the function was optimized. | |
| 5489 inline int opt_count(); | 5490 inline int opt_count(); |
| 5490 inline void set_opt_count(int opt_count); | 5491 inline void set_opt_count(int opt_count); |
| 5491 | 5492 |
| 5493 // Number of times the function was deoptimized. | |
| 5494 inline void set_deopt_count(int value); | |
| 5495 inline int deopt_count(); | |
| 5496 inline void increment_deopt_count(); | |
| 5497 | |
| 5498 // Number of time we tried to re-enable optimization after it | |
| 5499 // was disabled due to high number of deoptimizations. | |
| 5500 inline void set_opt_reenable_tries(int value); | |
| 5501 inline int opt_reenable_tries(); | |
| 5502 | |
| 5503 inline void TryReenableOptimization(); | |
| 5504 | |
| 5505 // Stores deopt_count, opt_reenable_tries and ic_age as bit-fields. | |
| 5506 inline void set_counters(int value); | |
| 5507 inline int counters(); | |
| 5508 | |
| 5509 | |
| 5492 // Source size of this function. | 5510 // Source size of this function. |
| 5493 int SourceSize(); | 5511 int SourceSize(); |
| 5494 | 5512 |
| 5495 // Calculate the instance size. | 5513 // Calculate the instance size. |
| 5496 int CalculateInstanceSize(); | 5514 int CalculateInstanceSize(); |
| 5497 | 5515 |
| 5498 // Calculate the number of in-object properties. | 5516 // Calculate the number of in-object properties. |
| 5499 int CalculateInObjectProperties(); | 5517 int CalculateInObjectProperties(); |
| 5500 | 5518 |
| 5501 // Dispatched behavior. | 5519 // Dispatched behavior. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5538 kConstructStubOffset + kPointerSize; | 5556 kConstructStubOffset + kPointerSize; |
| 5539 static const int kFunctionDataOffset = | 5557 static const int kFunctionDataOffset = |
| 5540 kInstanceClassNameOffset + kPointerSize; | 5558 kInstanceClassNameOffset + kPointerSize; |
| 5541 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; | 5559 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; |
| 5542 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 5560 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
| 5543 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; | 5561 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
| 5544 static const int kInitialMapOffset = | 5562 static const int kInitialMapOffset = |
| 5545 kInferredNameOffset + kPointerSize; | 5563 kInferredNameOffset + kPointerSize; |
| 5546 static const int kThisPropertyAssignmentsOffset = | 5564 static const int kThisPropertyAssignmentsOffset = |
| 5547 kInitialMapOffset + kPointerSize; | 5565 kInitialMapOffset + kPointerSize; |
| 5548 // ic_age is a Smi field. It could be grouped with another Smi field into a | 5566 // ast_node_count is a Smi field. It could be grouped with another Smi field |
| 5549 // PSEUDO_SMI_ACCESSORS pair (on x64), if one becomes available. | 5567 // into a PSEUDO_SMI_ACCESSORS pair (on x64), if one becomes available. |
| 5550 static const int kICAgeOffset = kThisPropertyAssignmentsOffset + kPointerSize; | 5568 static const int kAstNodeCountOffset = |
| 5569 kThisPropertyAssignmentsOffset + kPointerSize; | |
| 5551 #if V8_HOST_ARCH_32_BIT | 5570 #if V8_HOST_ARCH_32_BIT |
| 5552 // Smi fields. | 5571 // Smi fields. |
| 5553 static const int kLengthOffset = | 5572 static const int kLengthOffset = |
| 5554 kICAgeOffset + kPointerSize; | 5573 kAstNodeCountOffset + kPointerSize; |
| 5555 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; | 5574 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; |
| 5556 static const int kExpectedNofPropertiesOffset = | 5575 static const int kExpectedNofPropertiesOffset = |
| 5557 kFormalParameterCountOffset + kPointerSize; | 5576 kFormalParameterCountOffset + kPointerSize; |
| 5558 static const int kNumLiteralsOffset = | 5577 static const int kNumLiteralsOffset = |
| 5559 kExpectedNofPropertiesOffset + kPointerSize; | 5578 kExpectedNofPropertiesOffset + kPointerSize; |
| 5560 static const int kStartPositionAndTypeOffset = | 5579 static const int kStartPositionAndTypeOffset = |
| 5561 kNumLiteralsOffset + kPointerSize; | 5580 kNumLiteralsOffset + kPointerSize; |
| 5562 static const int kEndPositionOffset = | 5581 static const int kEndPositionOffset = |
| 5563 kStartPositionAndTypeOffset + kPointerSize; | 5582 kStartPositionAndTypeOffset + kPointerSize; |
| 5564 static const int kFunctionTokenPositionOffset = | 5583 static const int kFunctionTokenPositionOffset = |
| 5565 kEndPositionOffset + kPointerSize; | 5584 kEndPositionOffset + kPointerSize; |
| 5566 static const int kCompilerHintsOffset = | 5585 static const int kCompilerHintsOffset = |
| 5567 kFunctionTokenPositionOffset + kPointerSize; | 5586 kFunctionTokenPositionOffset + kPointerSize; |
| 5568 static const int kThisPropertyAssignmentsCountOffset = | 5587 static const int kThisPropertyAssignmentsCountOffset = |
| 5569 kCompilerHintsOffset + kPointerSize; | 5588 kCompilerHintsOffset + kPointerSize; |
| 5570 static const int kOptCountOffset = | 5589 static const int kOptCountOffset = |
| 5571 kThisPropertyAssignmentsCountOffset + kPointerSize; | 5590 kThisPropertyAssignmentsCountOffset + kPointerSize; |
| 5572 static const int kAstNodeCountOffset = kOptCountOffset + kPointerSize; | 5591 static const int kCountersOffset = kOptCountOffset + kPointerSize; |
| 5573 static const int kDeoptCounterOffset = kAstNodeCountOffset + kPointerSize; | 5592 static const int kStressDeoptCounterOffset = kCountersOffset + kPointerSize; |
| 5574 | |
| 5575 | 5593 |
| 5576 // Total size. | 5594 // Total size. |
| 5577 static const int kSize = kDeoptCounterOffset + kPointerSize; | 5595 static const int kSize = kStressDeoptCounterOffset + kPointerSize; |
| 5578 #else | 5596 #else |
| 5579 // The only reason to use smi fields instead of int fields | 5597 // The only reason to use smi fields instead of int fields |
| 5580 // is to allow iteration without maps decoding during | 5598 // is to allow iteration without maps decoding during |
| 5581 // garbage collections. | 5599 // garbage collections. |
| 5582 // To avoid wasting space on 64-bit architectures we use | 5600 // To avoid wasting space on 64-bit architectures we use |
| 5583 // the following trick: we group integer fields into pairs | 5601 // the following trick: we group integer fields into pairs |
| 5584 // First integer in each pair is shifted left by 1. | 5602 // First integer in each pair is shifted left by 1. |
| 5585 // By doing this we guarantee that LSB of each kPointerSize aligned | 5603 // By doing this we guarantee that LSB of each kPointerSize aligned |
| 5586 // word is not set and thus this word cannot be treated as pointer | 5604 // word is not set and thus this word cannot be treated as pointer |
| 5587 // to HeapObject during old space traversal. | 5605 // to HeapObject during old space traversal. |
| 5588 static const int kLengthOffset = | 5606 static const int kLengthOffset = |
| 5589 kICAgeOffset + kPointerSize; | 5607 kAstNodeCountOffset + kPointerSize; |
| 5590 static const int kFormalParameterCountOffset = | 5608 static const int kFormalParameterCountOffset = |
| 5591 kLengthOffset + kIntSize; | 5609 kLengthOffset + kIntSize; |
| 5592 | 5610 |
| 5593 static const int kExpectedNofPropertiesOffset = | 5611 static const int kExpectedNofPropertiesOffset = |
| 5594 kFormalParameterCountOffset + kIntSize; | 5612 kFormalParameterCountOffset + kIntSize; |
| 5595 static const int kNumLiteralsOffset = | 5613 static const int kNumLiteralsOffset = |
| 5596 kExpectedNofPropertiesOffset + kIntSize; | 5614 kExpectedNofPropertiesOffset + kIntSize; |
| 5597 | 5615 |
| 5598 static const int kEndPositionOffset = | 5616 static const int kEndPositionOffset = |
| 5599 kNumLiteralsOffset + kIntSize; | 5617 kNumLiteralsOffset + kIntSize; |
| 5600 static const int kStartPositionAndTypeOffset = | 5618 static const int kStartPositionAndTypeOffset = |
| 5601 kEndPositionOffset + kIntSize; | 5619 kEndPositionOffset + kIntSize; |
| 5602 | 5620 |
| 5603 static const int kFunctionTokenPositionOffset = | 5621 static const int kFunctionTokenPositionOffset = |
| 5604 kStartPositionAndTypeOffset + kIntSize; | 5622 kStartPositionAndTypeOffset + kIntSize; |
| 5605 static const int kCompilerHintsOffset = | 5623 static const int kCompilerHintsOffset = |
| 5606 kFunctionTokenPositionOffset + kIntSize; | 5624 kFunctionTokenPositionOffset + kIntSize; |
| 5607 | 5625 |
| 5608 static const int kThisPropertyAssignmentsCountOffset = | 5626 static const int kThisPropertyAssignmentsCountOffset = |
| 5609 kCompilerHintsOffset + kIntSize; | 5627 kCompilerHintsOffset + kIntSize; |
| 5610 static const int kOptCountOffset = | 5628 static const int kOptCountOffset = |
| 5611 kThisPropertyAssignmentsCountOffset + kIntSize; | 5629 kThisPropertyAssignmentsCountOffset + kIntSize; |
| 5612 | 5630 |
| 5613 static const int kAstNodeCountOffset = kOptCountOffset + kIntSize; | 5631 static const int kCountersOffset = kOptCountOffset + kIntSize; |
| 5614 static const int kDeoptCounterOffset = kAstNodeCountOffset + kIntSize; | 5632 static const int kStressDeoptCounterOffset = kCountersOffset + kIntSize; |
| 5615 | 5633 |
| 5616 // Total size. | 5634 // Total size. |
| 5617 static const int kSize = kDeoptCounterOffset + kIntSize; | 5635 static const int kSize = kStressDeoptCounterOffset + kIntSize; |
| 5618 | 5636 |
| 5619 #endif | 5637 #endif |
| 5620 | 5638 |
| 5621 // The construction counter for inobject slack tracking is stored in the | 5639 // The construction counter for inobject slack tracking is stored in the |
| 5622 // most significant byte of compiler_hints which is otherwise unused. | 5640 // most significant byte of compiler_hints which is otherwise unused. |
| 5623 // Its offset depends on the endian-ness of the architecture. | 5641 // Its offset depends on the endian-ness of the architecture. |
| 5624 #if __BYTE_ORDER == __LITTLE_ENDIAN | 5642 #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 5625 static const int kConstructionCountOffset = kCompilerHintsOffset + 3; | 5643 static const int kConstructionCountOffset = kCompilerHintsOffset + 3; |
| 5626 #elif __BYTE_ORDER == __BIG_ENDIAN | 5644 #elif __BYTE_ORDER == __BIG_ENDIAN |
| 5627 static const int kConstructionCountOffset = kCompilerHintsOffset + 0; | 5645 static const int kConstructionCountOffset = kCompilerHintsOffset + 0; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5660 kNative, | 5678 kNative, |
| 5661 kBoundFunction, | 5679 kBoundFunction, |
| 5662 kIsAnonymous, | 5680 kIsAnonymous, |
| 5663 kNameShouldPrintAsAnonymous, | 5681 kNameShouldPrintAsAnonymous, |
| 5664 kIsFunction, | 5682 kIsFunction, |
| 5665 kDontOptimize, | 5683 kDontOptimize, |
| 5666 kDontInline, | 5684 kDontInline, |
| 5667 kCompilerHintsCount // Pseudo entry | 5685 kCompilerHintsCount // Pseudo entry |
| 5668 }; | 5686 }; |
| 5669 | 5687 |
| 5688 static const int kDeoptCountSize = 4; | |
| 5689 static const int kDeoptCountMask = (1 << kDeoptCountSize) - 1; | |
| 5690 | |
| 5691 static const int kOptReenableTriesSize = 18; | |
| 5692 static const int kOptReenableTriesMask = (1 << kOptReenableTriesSize) - 1; | |
| 5693 | |
| 5694 static const int kICAgeSize = 8; | |
| 5695 static const int kICAgeMask = (1 << kICAgeSize) - 1; | |
| 5696 | |
| 5697 enum Counters { | |
| 5698 kDeoptCountShift, | |
|
Jakob Kummerow
2012/06/11 12:13:59
Don't you want to set kDeoptCountShift = kCounters
ulan
2012/06/11 16:07:31
set_counters takes care of this, removed kCounters
| |
| 5699 kOptReenableTriesShift = kDeoptCountShift + kDeoptCountSize, | |
| 5700 kICAgeShift = kOptReenableTriesShift + kOptReenableTriesSize, | |
| 5701 kCountersSizeInBits = kICAgeShift + kICAgeSize // Pseudo entry | |
| 5702 }; | |
| 5703 | |
| 5670 private: | 5704 private: |
| 5671 #if V8_HOST_ARCH_32_BIT | 5705 #if V8_HOST_ARCH_32_BIT |
| 5672 // On 32 bit platforms, compiler hints is a smi. | 5706 // On 32 bit platforms, compiler hints is a smi. |
| 5673 static const int kCompilerHintsSmiTagSize = kSmiTagSize; | 5707 static const int kCompilerHintsSmiTagSize = kSmiTagSize; |
| 5674 static const int kCompilerHintsSize = kPointerSize; | 5708 static const int kCompilerHintsSize = kPointerSize; |
| 5709 | |
| 5710 static const int kCountersSmiTagSize = kSmiTagSize; | |
| 5711 static const int kCountersSize = kPointerSize; | |
| 5675 #else | 5712 #else |
| 5676 // On 64 bit platforms, compiler hints is not a smi, see comment above. | 5713 // On 64 bit platforms, compiler hints is not a smi, see comment above. |
| 5677 static const int kCompilerHintsSmiTagSize = 0; | 5714 static const int kCompilerHintsSmiTagSize = 0; |
| 5678 static const int kCompilerHintsSize = kIntSize; | 5715 static const int kCompilerHintsSize = kIntSize; |
| 5716 | |
| 5717 static const int kCountersSmiTagSize = 0; | |
| 5718 static const int kCountersSize = kIntSize; | |
| 5679 #endif | 5719 #endif |
| 5680 | 5720 |
| 5681 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= | 5721 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= |
| 5682 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); | 5722 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); |
| 5683 | 5723 |
| 5724 STATIC_ASSERT(SharedFunctionInfo::kCountersSizeInBits <= | |
| 5725 SharedFunctionInfo::kCountersSize * kBitsPerByte); | |
| 5684 public: | 5726 public: |
| 5685 // Constants for optimizing codegen for strict mode function and | 5727 // Constants for optimizing codegen for strict mode function and |
| 5686 // native tests. | 5728 // native tests. |
| 5687 // Allows to use byte-width instructions. | 5729 // Allows to use byte-width instructions. |
| 5688 static const int kStrictModeBitWithinByte = | 5730 static const int kStrictModeBitWithinByte = |
| 5689 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 5731 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
| 5690 | 5732 |
| 5691 static const int kExtendedModeBitWithinByte = | 5733 static const int kExtendedModeBitWithinByte = |
| 5692 (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 5734 (kExtendedModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
| 5693 | 5735 |
| (...skipping 2984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8678 } else { | 8720 } else { |
| 8679 value &= ~(1 << bit_position); | 8721 value &= ~(1 << bit_position); |
| 8680 } | 8722 } |
| 8681 return value; | 8723 return value; |
| 8682 } | 8724 } |
| 8683 }; | 8725 }; |
| 8684 | 8726 |
| 8685 } } // namespace v8::internal | 8727 } } // namespace v8::internal |
| 8686 | 8728 |
| 8687 #endif // V8_OBJECTS_H_ | 8729 #endif // V8_OBJECTS_H_ |
| OLD | NEW |