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 3599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3610 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) | 3610 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) |
3611 ACCESSORS(SharedFunctionInfo, initial_map, Object, kInitialMapOffset) | 3611 ACCESSORS(SharedFunctionInfo, initial_map, Object, kInitialMapOffset) |
3612 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, | 3612 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, |
3613 kInstanceClassNameOffset) | 3613 kInstanceClassNameOffset) |
3614 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) | 3614 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) |
3615 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) | 3615 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) |
3616 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) | 3616 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) |
3617 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) | 3617 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) |
3618 ACCESSORS(SharedFunctionInfo, this_property_assignments, Object, | 3618 ACCESSORS(SharedFunctionInfo, this_property_assignments, Object, |
3619 kThisPropertyAssignmentsOffset) | 3619 kThisPropertyAssignmentsOffset) |
3620 SMI_ACCESSORS(SharedFunctionInfo, ic_age, kICAgeOffset) | 3620 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) |
3621 | 3621 |
3622 | 3622 |
3623 BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, | 3623 BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, |
3624 kHiddenPrototypeBit) | 3624 kHiddenPrototypeBit) |
3625 BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit) | 3625 BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit) |
3626 BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check, | 3626 BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check, |
3627 kNeedsAccessCheckBit) | 3627 kNeedsAccessCheckBit) |
3628 BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype, | 3628 BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype, |
3629 kReadOnlyPrototypeBit) | 3629 kReadOnlyPrototypeBit) |
3630 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, | 3630 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, |
(...skipping 28 matching lines...) Expand all Loading... | |
3659 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type, | 3659 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type, |
3660 kStartPositionAndTypeOffset) | 3660 kStartPositionAndTypeOffset) |
3661 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) | 3661 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) |
3662 SMI_ACCESSORS(SharedFunctionInfo, function_token_position, | 3662 SMI_ACCESSORS(SharedFunctionInfo, function_token_position, |
3663 kFunctionTokenPositionOffset) | 3663 kFunctionTokenPositionOffset) |
3664 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, | 3664 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, |
3665 kCompilerHintsOffset) | 3665 kCompilerHintsOffset) |
3666 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, | 3666 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, |
3667 kThisPropertyAssignmentsCountOffset) | 3667 kThisPropertyAssignmentsCountOffset) |
3668 SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) | 3668 SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) |
3669 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 3669 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) |
3670 SMI_ACCESSORS(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) | 3670 SMI_ACCESSORS(SharedFunctionInfo, |
3671 stress_deopt_counter, | |
3672 kStressDeoptCounterOffset) | |
3671 #else | 3673 #else |
3672 | 3674 |
3673 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ | 3675 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ |
3674 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ | 3676 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ |
3675 int holder::name() { \ | 3677 int holder::name() { \ |
3676 int value = READ_INT_FIELD(this, offset); \ | 3678 int value = READ_INT_FIELD(this, offset); \ |
3677 ASSERT(kHeapObjectTag == 1); \ | 3679 ASSERT(kHeapObjectTag == 1); \ |
3678 ASSERT((value & kHeapObjectTag) == 0); \ | 3680 ASSERT((value & kHeapObjectTag) == 0); \ |
3679 return value >> 1; \ | 3681 return value >> 1; \ |
3680 } \ | 3682 } \ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3712 kFunctionTokenPositionOffset) | 3714 kFunctionTokenPositionOffset) |
3713 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, | 3715 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, |
3714 compiler_hints, | 3716 compiler_hints, |
3715 kCompilerHintsOffset) | 3717 kCompilerHintsOffset) |
3716 | 3718 |
3717 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, | 3719 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, |
3718 this_property_assignments_count, | 3720 this_property_assignments_count, |
3719 kThisPropertyAssignmentsCountOffset) | 3721 kThisPropertyAssignmentsCountOffset) |
3720 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset) | 3722 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset) |
3721 | 3723 |
3722 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 3724 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, counters, kCountersOffset) |
3723 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) | 3725 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, |
3726 stress_deopt_counter, | |
3727 kStressDeoptCounterOffset) | |
3724 #endif | 3728 #endif |
3725 | 3729 |
3726 | 3730 |
3727 int SharedFunctionInfo::construction_count() { | 3731 int SharedFunctionInfo::construction_count() { |
3728 return READ_BYTE_FIELD(this, kConstructionCountOffset); | 3732 return READ_BYTE_FIELD(this, kConstructionCountOffset); |
3729 } | 3733 } |
3730 | 3734 |
3731 | 3735 |
3732 void SharedFunctionInfo::set_construction_count(int value) { | 3736 void SharedFunctionInfo::set_construction_count(int value) { |
3733 ASSERT(0 <= value && value < 256); | 3737 ASSERT(0 <= value && value < 256); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3914 return (compiler_hints() >> kCodeAgeShift) & kCodeAgeMask; | 3918 return (compiler_hints() >> kCodeAgeShift) & kCodeAgeMask; |
3915 } | 3919 } |
3916 | 3920 |
3917 | 3921 |
3918 void SharedFunctionInfo::set_code_age(int code_age) { | 3922 void SharedFunctionInfo::set_code_age(int code_age) { |
3919 int hints = compiler_hints() & ~(kCodeAgeMask << kCodeAgeShift); | 3923 int hints = compiler_hints() & ~(kCodeAgeMask << kCodeAgeShift); |
3920 set_compiler_hints(hints | ((code_age & kCodeAgeMask) << kCodeAgeShift)); | 3924 set_compiler_hints(hints | ((code_age & kCodeAgeMask) << kCodeAgeShift)); |
3921 } | 3925 } |
3922 | 3926 |
3923 | 3927 |
3928 int SharedFunctionInfo::ic_age() { | |
Jakob Kummerow
2012/06/11 12:13:59
Y U NO use BitField<type, shift, size>? That'd aut
ulan
2012/06/11 16:07:31
Yeah, BitField is cleaner. Done.
| |
3929 return (counters() >> kICAgeShift) & kICAgeMask; | |
3930 } | |
3931 | |
3932 | |
3933 void SharedFunctionInfo::set_ic_age(int ic_age) { | |
3934 ASSERT(ic_age <= kICAgeMask); | |
3935 int value = counters() & ~(kICAgeMask << kICAgeShift); | |
3936 set_counters(value | ((ic_age & kICAgeMask) << kICAgeShift)); | |
3937 } | |
3938 | |
3939 | |
3940 int SharedFunctionInfo::deopt_count() { | |
3941 return (counters() >> kDeoptCountShift) & kDeoptCountMask; | |
3942 } | |
3943 | |
3944 | |
3945 void SharedFunctionInfo::set_deopt_count(int deopt_count) { | |
3946 ASSERT(deopt_count <= kDeoptCountMask); | |
3947 int value = counters() & ~(kDeoptCountMask << kDeoptCountShift); | |
3948 set_counters(value | ((deopt_count & kDeoptCountMask) << kDeoptCountShift)); | |
3949 } | |
3950 | |
3951 | |
3952 void SharedFunctionInfo::increment_deopt_count() { | |
3953 int value = counters(); | |
3954 int deopt_count = (value >> kDeoptCountShift) & kDeoptCountMask; | |
3955 deopt_count++; | |
3956 value &= ~(kDeoptCountMask << kDeoptCountShift); | |
3957 set_counters(value | ((deopt_count & kDeoptCountMask) << kDeoptCountShift)); | |
3958 } | |
3959 | |
3960 | |
3961 int SharedFunctionInfo::opt_reenable_tries() { | |
3962 return (counters() >> kOptReenableTriesShift) & kOptReenableTriesMask; | |
3963 } | |
3964 | |
3965 | |
3966 void SharedFunctionInfo::set_opt_reenable_tries(int tries) { | |
3967 ASSERT(tries <= kOptReenableTriesMask); | |
3968 int value = counters() & ~(kOptReenableTriesMask << kOptReenableTriesShift); | |
3969 value |= ((tries & kOptReenableTriesMask) << kOptReenableTriesShift); | |
3970 set_counters(value); | |
3971 } | |
3972 | |
3973 | |
3924 bool SharedFunctionInfo::has_deoptimization_support() { | 3974 bool SharedFunctionInfo::has_deoptimization_support() { |
3925 Code* code = this->code(); | 3975 Code* code = this->code(); |
3926 return code->kind() == Code::FUNCTION && code->has_deoptimization_support(); | 3976 return code->kind() == Code::FUNCTION && code->has_deoptimization_support(); |
3927 } | 3977 } |
3928 | 3978 |
3929 | 3979 |
3980 void SharedFunctionInfo::TryReenableOptimization() { | |
3981 int tries = opt_reenable_tries(); | |
3982 set_opt_reenable_tries(tries + 1); | |
3983 // We reenable optimization whenever the number of tries is a large | |
3984 // enough power of 2. | |
3985 if (tries >= 16 && (((tries - 1) & tries) == 0)) { | |
3986 set_optimization_disabled(false); | |
3987 set_opt_count(0); | |
3988 set_deopt_count(0); | |
3989 code()->set_optimizable(true); | |
3990 } | |
3991 } | |
3992 | |
3993 | |
3930 bool JSFunction::IsBuiltin() { | 3994 bool JSFunction::IsBuiltin() { |
3931 return context()->global()->IsJSBuiltinsObject(); | 3995 return context()->global()->IsJSBuiltinsObject(); |
3932 } | 3996 } |
3933 | 3997 |
3934 | 3998 |
3935 bool JSFunction::NeedsArgumentsAdaption() { | 3999 bool JSFunction::NeedsArgumentsAdaption() { |
3936 return shared()->formal_parameter_count() != | 4000 return shared()->formal_parameter_count() != |
3937 SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 4001 SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
3938 } | 4002 } |
3939 | 4003 |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5062 #undef WRITE_UINT32_FIELD | 5126 #undef WRITE_UINT32_FIELD |
5063 #undef READ_SHORT_FIELD | 5127 #undef READ_SHORT_FIELD |
5064 #undef WRITE_SHORT_FIELD | 5128 #undef WRITE_SHORT_FIELD |
5065 #undef READ_BYTE_FIELD | 5129 #undef READ_BYTE_FIELD |
5066 #undef WRITE_BYTE_FIELD | 5130 #undef WRITE_BYTE_FIELD |
5067 | 5131 |
5068 | 5132 |
5069 } } // namespace v8::internal | 5133 } } // namespace v8::internal |
5070 | 5134 |
5071 #endif // V8_OBJECTS_INL_H_ | 5135 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |