OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 3707 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
3708 static const int kEvalFrominstructionsOffsetOffset = | 3708 static const int kEvalFrominstructionsOffsetOffset = |
3709 kEvalFromSharedOffset + kPointerSize; | 3709 kEvalFromSharedOffset + kPointerSize; |
3710 static const int kSize = kEvalFrominstructionsOffsetOffset + kPointerSize; | 3710 static const int kSize = kEvalFrominstructionsOffsetOffset + kPointerSize; |
3711 | 3711 |
3712 private: | 3712 private: |
3713 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); | 3713 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); |
3714 }; | 3714 }; |
3715 | 3715 |
3716 | 3716 |
3717 enum MathFunctionId { | 3717 // List of builtin functions we want to identify to improve code |
3718 kNotSpecialMathFunction = 0, | 3718 // generation. |
3719 // These numbers must be kept in sync with the ones in math.js. | 3719 // |
3720 kMathFloor = 1, | 3720 // Each entry has a name of a global object property holding an object |
3721 kMathRound = 2, | 3721 // optionally followed by ".prototype", a name of a builtin function |
3722 kMathCeil = 3, | 3722 // on the object (the one the id is set for), and a label. |
3723 kMathAbs = 4, | 3723 // |
3724 kMathLog = 5, | 3724 // Installation of ids for the selected builtin functions is handled |
3725 kMathSin = 6, | 3725 // by the bootstrapper. |
3726 kMathCos = 7, | 3726 // |
3727 kMathTan = 8, | 3727 // NOTE: Order is important: math functions should be at the end of |
3728 kMathASin = 9, | 3728 // the list and MathFloor should be the first math function. |
3729 kMathACos = 0xa, | 3729 #define FUNCTIONS_WITH_ID_LIST(V) \ |
3730 kMathATan = 0xb, | 3730 V(Array.prototype, push, ArrayPush) \ |
3731 kMathExp = 0xc, | 3731 V(Array.prototype, pop, ArrayPop) \ |
3732 kMathSqrt = 0xd, | 3732 V(String.prototype, charCodeAt, StringCharCodeAt) \ |
3733 kMathPow = 0xe, | 3733 V(String.prototype, charAt, StringCharAt) \ |
3734 kMathPowHalf = 0xf | 3734 V(String, fromCharCode, StringFromCharCode) \ |
| 3735 V(Math, floor, MathFloor) \ |
| 3736 V(Math, round, MathRound) \ |
| 3737 V(Math, ceil, MathCeil) \ |
| 3738 V(Math, abs, MathAbs) \ |
| 3739 V(Math, log, MathLog) \ |
| 3740 V(Math, sin, MathSin) \ |
| 3741 V(Math, cos, MathCos) \ |
| 3742 V(Math, tan, MathTan) \ |
| 3743 V(Math, asin, MathASin) \ |
| 3744 V(Math, acos, MathACos) \ |
| 3745 V(Math, atan, MathATan) \ |
| 3746 V(Math, exp, MathExp) \ |
| 3747 V(Math, sqrt, MathSqrt) \ |
| 3748 V(Math, pow, MathPow) |
| 3749 |
| 3750 |
| 3751 enum BuiltinFunctionId { |
| 3752 #define DECLARE_FUNCTION_ID(ignored1, ignore2, name) \ |
| 3753 k##name, |
| 3754 FUNCTIONS_WITH_ID_LIST(DECLARE_FUNCTION_ID) |
| 3755 #undef DECLARE_FUNCTION_ID |
| 3756 // Fake id for a special case of Math.pow. Note, it continues the |
| 3757 // list of math functions. |
| 3758 kMathPowHalf |
3735 }; | 3759 }; |
3736 | 3760 |
3737 | 3761 |
3738 // SharedFunctionInfo describes the JSFunction information that can be | 3762 // SharedFunctionInfo describes the JSFunction information that can be |
3739 // shared by multiple instances of the function. | 3763 // shared by multiple instances of the function. |
3740 class SharedFunctionInfo: public HeapObject { | 3764 class SharedFunctionInfo: public HeapObject { |
3741 public: | 3765 public: |
3742 // [name]: Function name. | 3766 // [name]: Function name. |
3743 DECL_ACCESSORS(name, Object) | 3767 DECL_ACCESSORS(name, Object) |
3744 | 3768 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3865 // May go back from true to false after GC. | 3889 // May go back from true to false after GC. |
3866 inline bool live_objects_may_exist(); | 3890 inline bool live_objects_may_exist(); |
3867 | 3891 |
3868 inline void set_live_objects_may_exist(bool value); | 3892 inline void set_live_objects_may_exist(bool value); |
3869 | 3893 |
3870 // [instance class name]: class name for instances. | 3894 // [instance class name]: class name for instances. |
3871 DECL_ACCESSORS(instance_class_name, Object) | 3895 DECL_ACCESSORS(instance_class_name, Object) |
3872 | 3896 |
3873 // [function data]: This field holds some additional data for function. | 3897 // [function data]: This field holds some additional data for function. |
3874 // Currently it either has FunctionTemplateInfo to make benefit the API | 3898 // Currently it either has FunctionTemplateInfo to make benefit the API |
3875 // or Smi identifying a custom call generator. | 3899 // or Smi identifying a builtin function. |
3876 // In the long run we don't want all functions to have this field but | 3900 // In the long run we don't want all functions to have this field but |
3877 // we can fix that when we have a better model for storing hidden data | 3901 // we can fix that when we have a better model for storing hidden data |
3878 // on objects. | 3902 // on objects. |
3879 DECL_ACCESSORS(function_data, Object) | 3903 DECL_ACCESSORS(function_data, Object) |
3880 | 3904 |
3881 inline bool IsApiFunction(); | 3905 inline bool IsApiFunction(); |
3882 inline FunctionTemplateInfo* get_api_func_data(); | 3906 inline FunctionTemplateInfo* get_api_func_data(); |
3883 inline bool HasCustomCallGenerator(); | 3907 inline bool HasBuiltinFunctionId(); |
3884 inline int custom_call_generator_id(); | 3908 inline bool IsBuiltinMathFunction(); |
| 3909 inline BuiltinFunctionId builtin_function_id(); |
3885 | 3910 |
3886 // [script info]: Script from which the function originates. | 3911 // [script info]: Script from which the function originates. |
3887 DECL_ACCESSORS(script, Object) | 3912 DECL_ACCESSORS(script, Object) |
3888 | 3913 |
3889 // [num_literals]: Number of literals used by this function. | 3914 // [num_literals]: Number of literals used by this function. |
3890 inline int num_literals(); | 3915 inline int num_literals(); |
3891 inline void set_num_literals(int value); | 3916 inline void set_num_literals(int value); |
3892 | 3917 |
3893 // [start_position_and_type]: Field used to store both the source code | 3918 // [start_position_and_type]: Field used to store both the source code |
3894 // position, whether or not the function is a function expression, | 3919 // position, whether or not the function is a function expression, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4125 #if __BYTE_ORDER == __LITTLE_ENDIAN | 4150 #if __BYTE_ORDER == __LITTLE_ENDIAN |
4126 static const int kConstructionCountOffset = kCompilerHintsOffset + 3; | 4151 static const int kConstructionCountOffset = kCompilerHintsOffset + 3; |
4127 #elif __BYTE_ORDER == __BIG_ENDIAN | 4152 #elif __BYTE_ORDER == __BIG_ENDIAN |
4128 static const int kConstructionCountOffset = kCompilerHintsOffset + 0; | 4153 static const int kConstructionCountOffset = kCompilerHintsOffset + 0; |
4129 #else | 4154 #else |
4130 #error Unknown byte ordering | 4155 #error Unknown byte ordering |
4131 #endif | 4156 #endif |
4132 | 4157 |
4133 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); | 4158 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); |
4134 | 4159 |
4135 // Get/set a special tag on the functions from math.js so we can inline | |
4136 // efficient versions of them in the code. | |
4137 inline MathFunctionId math_function_id(); | |
4138 inline void set_math_function_id(int id); | |
4139 static inline int max_math_id_number() { return kMathFunctionMask; } | |
4140 | |
4141 typedef FixedBodyDescriptor<kNameOffset, | 4160 typedef FixedBodyDescriptor<kNameOffset, |
4142 kThisPropertyAssignmentsOffset + kPointerSize, | 4161 kThisPropertyAssignmentsOffset + kPointerSize, |
4143 kSize> BodyDescriptor; | 4162 kSize> BodyDescriptor; |
4144 | 4163 |
4145 private: | 4164 private: |
4146 // Bit positions in start_position_and_type. | 4165 // Bit positions in start_position_and_type. |
4147 // The source code start position is in the 30 most significant bits of | 4166 // The source code start position is in the 30 most significant bits of |
4148 // the start_position_and_type field. | 4167 // the start_position_and_type field. |
4149 static const int kIsExpressionBit = 0; | 4168 static const int kIsExpressionBit = 0; |
4150 static const int kIsTopLevelBit = 1; | 4169 static const int kIsTopLevelBit = 1; |
4151 static const int kStartPositionShift = 2; | 4170 static const int kStartPositionShift = 2; |
4152 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 4171 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
4153 | 4172 |
4154 // Bit positions in compiler_hints. | 4173 // Bit positions in compiler_hints. |
4155 static const int kHasOnlySimpleThisPropertyAssignments = 0; | 4174 static const int kHasOnlySimpleThisPropertyAssignments = 0; |
4156 static const int kTryFullCodegen = 1; | 4175 static const int kTryFullCodegen = 1; |
4157 static const int kAllowLazyCompilation = 2; | 4176 static const int kAllowLazyCompilation = 2; |
4158 static const int kMathFunctionShift = 3; | 4177 static const int kLiveObjectsMayExist = 3; |
4159 static const int kMathFunctionMask = 0x1f; | 4178 static const int kCodeAgeShift = 4; |
4160 static const int kLiveObjectsMayExist = 8; | |
4161 static const int kCodeAgeShift = 9; | |
4162 static const int kCodeAgeMask = 0x7; | 4179 static const int kCodeAgeMask = 0x7; |
4163 static const int kOptimizationDisabled = 12; | 4180 static const int kOptimizationDisabled = 7; |
4164 | 4181 |
4165 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); | 4182 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); |
4166 }; | 4183 }; |
4167 | 4184 |
4168 | 4185 |
4169 // JSFunction describes JavaScript functions. | 4186 // JSFunction describes JavaScript functions. |
4170 class JSFunction: public JSObject { | 4187 class JSFunction: public JSObject { |
4171 public: | 4188 public: |
4172 // [prototype_or_initial_map]: | 4189 // [prototype_or_initial_map]: |
4173 DECL_ACCESSORS(prototype_or_initial_map, Object) | 4190 DECL_ACCESSORS(prototype_or_initial_map, Object) |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6101 } else { | 6118 } else { |
6102 value &= ~(1 << bit_position); | 6119 value &= ~(1 << bit_position); |
6103 } | 6120 } |
6104 return value; | 6121 return value; |
6105 } | 6122 } |
6106 }; | 6123 }; |
6107 | 6124 |
6108 } } // namespace v8::internal | 6125 } } // namespace v8::internal |
6109 | 6126 |
6110 #endif // V8_OBJECTS_H_ | 6127 #endif // V8_OBJECTS_H_ |
OLD | NEW |