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 4648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4659 | 4659 |
4660 // Position of this function in the script source. | 4660 // Position of this function in the script source. |
4661 inline int start_position(); | 4661 inline int start_position(); |
4662 inline void set_start_position(int start_position); | 4662 inline void set_start_position(int start_position); |
4663 | 4663 |
4664 // End position of this function in the script source. | 4664 // End position of this function in the script source. |
4665 inline int end_position(); | 4665 inline int end_position(); |
4666 inline void set_end_position(int end_position); | 4666 inline void set_end_position(int end_position); |
4667 | 4667 |
4668 // Is this function a function expression in the source code. | 4668 // Is this function a function expression in the source code. |
4669 inline bool is_expression(); | 4669 DECL_BOOLEAN_ACCESSORS(is_expression) |
4670 inline void set_is_expression(bool value); | |
4671 | 4670 |
4672 // Is this function a top-level function (scripts, evals). | 4671 // Is this function a top-level function (scripts, evals). |
4673 inline bool is_toplevel(); | 4672 DECL_BOOLEAN_ACCESSORS(is_toplevel) |
4674 inline void set_is_toplevel(bool value); | |
4675 | 4673 |
4676 // Bit field containing various information collected by the compiler to | 4674 // Bit field containing various information collected by the compiler to |
4677 // drive optimization. | 4675 // drive optimization. |
4678 inline int compiler_hints(); | 4676 inline int compiler_hints(); |
4679 inline void set_compiler_hints(int value); | 4677 inline void set_compiler_hints(int value); |
4680 | 4678 |
4681 // A counter used to determine when to stress the deoptimizer with a | 4679 // A counter used to determine when to stress the deoptimizer with a |
4682 // deopt. | 4680 // deopt. |
4683 inline Smi* deopt_counter(); | 4681 inline Smi* deopt_counter(); |
4684 inline void set_deopt_counter(Smi* counter); | 4682 inline void set_deopt_counter(Smi* counter); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4720 // False if the function definitely does not allocate an arguments object. | 4718 // False if the function definitely does not allocate an arguments object. |
4721 DECL_BOOLEAN_ACCESSORS(uses_arguments) | 4719 DECL_BOOLEAN_ACCESSORS(uses_arguments) |
4722 | 4720 |
4723 // True if the function has any duplicated parameter names. | 4721 // True if the function has any duplicated parameter names. |
4724 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) | 4722 DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters) |
4725 | 4723 |
4726 // Indicates whether the function is a native function. | 4724 // Indicates whether the function is a native function. |
4727 // These needs special threatment in .call and .apply since | 4725 // These needs special threatment in .call and .apply since |
4728 // null passed as the receiver should not be translated to the | 4726 // null passed as the receiver should not be translated to the |
4729 // global object. | 4727 // global object. |
4730 inline bool native(); | 4728 DECL_BOOLEAN_ACCESSORS(native) |
4731 inline void set_native(bool value); | 4729 |
| 4730 // Indicates that the function was created by the Function function. |
| 4731 // Though it's anonymous, toString should treat it as if it had the name |
| 4732 // "anonymous". We don't set the name itself so that the system does not |
| 4733 // see a binding for it. |
| 4734 DECL_BOOLEAN_ACCESSORS(name_should_print_as_anonymous) |
4732 | 4735 |
4733 // Indicates whether the function is a bound function created using | 4736 // Indicates whether the function is a bound function created using |
4734 // the bind function. | 4737 // the bind function. |
4735 inline bool bound(); | 4738 DECL_BOOLEAN_ACCESSORS(bound) |
4736 inline void set_bound(bool value); | 4739 |
| 4740 // Indicates that the function is anonymous (the name field can be set |
| 4741 // through the API, which does not change this flag). |
| 4742 DECL_BOOLEAN_ACCESSORS(is_anonymous) |
4737 | 4743 |
4738 // Indicates whether or not the code in the shared function support | 4744 // Indicates whether or not the code in the shared function support |
4739 // deoptimization. | 4745 // deoptimization. |
4740 inline bool has_deoptimization_support(); | 4746 inline bool has_deoptimization_support(); |
4741 | 4747 |
4742 // Enable deoptimization support through recompiled code. | 4748 // Enable deoptimization support through recompiled code. |
4743 void EnableDeoptimizationSupport(Code* recompiled); | 4749 void EnableDeoptimizationSupport(Code* recompiled); |
4744 | 4750 |
4745 // Disable (further) attempted optimization of all functions sharing this | 4751 // Disable (further) attempted optimization of all functions sharing this |
4746 // shared function info. The function is the one we actually tried to | 4752 // shared function info. The function is the one we actually tried to |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4908 // The source code start position is in the 30 most significant bits of | 4914 // The source code start position is in the 30 most significant bits of |
4909 // the start_position_and_type field. | 4915 // the start_position_and_type field. |
4910 static const int kIsExpressionBit = 0; | 4916 static const int kIsExpressionBit = 0; |
4911 static const int kIsTopLevelBit = 1; | 4917 static const int kIsTopLevelBit = 1; |
4912 static const int kStartPositionShift = 2; | 4918 static const int kStartPositionShift = 2; |
4913 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 4919 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
4914 | 4920 |
4915 // Bit positions in compiler_hints. | 4921 // Bit positions in compiler_hints. |
4916 static const int kCodeAgeSize = 3; | 4922 static const int kCodeAgeSize = 3; |
4917 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; | 4923 static const int kCodeAgeMask = (1 << kCodeAgeSize) - 1; |
4918 static const int kBoundFunction = 9; | |
4919 | 4924 |
4920 enum CompilerHints { | 4925 enum CompilerHints { |
4921 kHasOnlySimpleThisPropertyAssignments, | 4926 kHasOnlySimpleThisPropertyAssignments, |
4922 kAllowLazyCompilation, | 4927 kAllowLazyCompilation, |
4923 kLiveObjectsMayExist, | 4928 kLiveObjectsMayExist, |
4924 kCodeAgeShift, | 4929 kCodeAgeShift, |
4925 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, | 4930 kOptimizationDisabled = kCodeAgeShift + kCodeAgeSize, |
4926 kStrictModeFunction, | 4931 kStrictModeFunction, |
4927 kUsesArguments, | 4932 kUsesArguments, |
4928 kHasDuplicateParameters, | 4933 kHasDuplicateParameters, |
4929 kNative | 4934 kNative, |
| 4935 kBoundFunction, |
| 4936 kIsAnonymous, |
| 4937 kNameShouldPrintAsAnonymous, |
| 4938 kCompilerHintsCount // Pseudo entry |
4930 }; | 4939 }; |
4931 | 4940 |
4932 private: | 4941 private: |
4933 #if V8_HOST_ARCH_32_BIT | 4942 #if V8_HOST_ARCH_32_BIT |
4934 // On 32 bit platforms, compiler hints is a smi. | 4943 // On 32 bit platforms, compiler hints is a smi. |
4935 static const int kCompilerHintsSmiTagSize = kSmiTagSize; | 4944 static const int kCompilerHintsSmiTagSize = kSmiTagSize; |
4936 static const int kCompilerHintsSize = kPointerSize; | 4945 static const int kCompilerHintsSize = kPointerSize; |
4937 #else | 4946 #else |
4938 // On 64 bit platforms, compiler hints is not a smi, see comment above. | 4947 // On 64 bit platforms, compiler hints is not a smi, see comment above. |
4939 static const int kCompilerHintsSmiTagSize = 0; | 4948 static const int kCompilerHintsSmiTagSize = 0; |
4940 static const int kCompilerHintsSize = kIntSize; | 4949 static const int kCompilerHintsSize = kIntSize; |
4941 #endif | 4950 #endif |
4942 | 4951 |
| 4952 STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= |
| 4953 SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); |
| 4954 |
4943 public: | 4955 public: |
4944 // Constants for optimizing codegen for strict mode function and | 4956 // Constants for optimizing codegen for strict mode function and |
4945 // native tests. | 4957 // native tests. |
4946 // Allows to use byte-widgh instructions. | 4958 // Allows to use byte-widgh instructions. |
4947 static const int kStrictModeBitWithinByte = | 4959 static const int kStrictModeBitWithinByte = |
4948 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; | 4960 (kStrictModeFunction + kCompilerHintsSmiTagSize) % kBitsPerByte; |
4949 | 4961 |
4950 static const int kNativeBitWithinByte = | 4962 static const int kNativeBitWithinByte = |
4951 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; | 4963 (kNative + kCompilerHintsSmiTagSize) % kBitsPerByte; |
4952 | 4964 |
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7312 } else { | 7324 } else { |
7313 value &= ~(1 << bit_position); | 7325 value &= ~(1 << bit_position); |
7314 } | 7326 } |
7315 return value; | 7327 return value; |
7316 } | 7328 } |
7317 }; | 7329 }; |
7318 | 7330 |
7319 } } // namespace v8::internal | 7331 } } // namespace v8::internal |
7320 | 7332 |
7321 #endif // V8_OBJECTS_H_ | 7333 #endif // V8_OBJECTS_H_ |
OLD | NEW |