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 3493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3504 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) | 3504 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) |
| 3505 ACCESSORS(SharedFunctionInfo, initial_map, Object, kInitialMapOffset) | 3505 ACCESSORS(SharedFunctionInfo, initial_map, Object, kInitialMapOffset) |
| 3506 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, | 3506 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, |
| 3507 kInstanceClassNameOffset) | 3507 kInstanceClassNameOffset) |
| 3508 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) | 3508 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) |
| 3509 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) | 3509 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) |
| 3510 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) | 3510 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) |
| 3511 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) | 3511 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) |
| 3512 ACCESSORS(SharedFunctionInfo, this_property_assignments, Object, | 3512 ACCESSORS(SharedFunctionInfo, this_property_assignments, Object, |
| 3513 kThisPropertyAssignmentsOffset) | 3513 kThisPropertyAssignmentsOffset) |
| 3514 SMI_ACCESSORS(SharedFunctionInfo, ic_age, kICAgeOffset) | |
| 3515 | 3514 |
| 3516 | 3515 |
| 3517 BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, | 3516 BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, |
| 3518 kHiddenPrototypeBit) | 3517 kHiddenPrototypeBit) |
| 3519 BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit) | 3518 BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit) |
| 3520 BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check, | 3519 BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check, |
| 3521 kNeedsAccessCheckBit) | 3520 kNeedsAccessCheckBit) |
| 3522 BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype, | 3521 BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype, |
| 3523 kReadOnlyPrototypeBit) | 3522 kReadOnlyPrototypeBit) |
| 3524 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, | 3523 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3555 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) | 3554 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) |
| 3556 SMI_ACCESSORS(SharedFunctionInfo, function_token_position, | 3555 SMI_ACCESSORS(SharedFunctionInfo, function_token_position, |
| 3557 kFunctionTokenPositionOffset) | 3556 kFunctionTokenPositionOffset) |
| 3558 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, | 3557 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, |
| 3559 kCompilerHintsOffset) | 3558 kCompilerHintsOffset) |
| 3560 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, | 3559 SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, |
| 3561 kThisPropertyAssignmentsCountOffset) | 3560 kThisPropertyAssignmentsCountOffset) |
| 3562 SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) | 3561 SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) |
| 3563 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 3562 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) |
| 3564 SMI_ACCESSORS(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) | 3563 SMI_ACCESSORS(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) |
| 3564 SMI_ACCESSORS(SharedFunctionInfo, ic_age, kICAgeOffset) | |
| 3565 SMI_ACCESSORS(SharedFunctionInfo, opt_reenable_tries, kOptReenableTriesOffset) | |
| 3565 #else | 3566 #else |
| 3566 | 3567 |
| 3567 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ | 3568 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ |
| 3568 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ | 3569 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ |
| 3569 int holder::name() { \ | 3570 int holder::name() { \ |
| 3570 int value = READ_INT_FIELD(this, offset); \ | 3571 int value = READ_INT_FIELD(this, offset); \ |
| 3571 ASSERT(kHeapObjectTag == 1); \ | 3572 ASSERT(kHeapObjectTag == 1); \ |
| 3572 ASSERT((value & kHeapObjectTag) == 0); \ | 3573 ASSERT((value & kHeapObjectTag) == 0); \ |
| 3573 return value >> 1; \ | 3574 return value >> 1; \ |
| 3574 } \ | 3575 } \ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3608 compiler_hints, | 3609 compiler_hints, |
| 3609 kCompilerHintsOffset) | 3610 kCompilerHintsOffset) |
| 3610 | 3611 |
| 3611 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, | 3612 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, |
| 3612 this_property_assignments_count, | 3613 this_property_assignments_count, |
| 3613 kThisPropertyAssignmentsCountOffset) | 3614 kThisPropertyAssignmentsCountOffset) |
| 3614 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset) | 3615 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset) |
| 3615 | 3616 |
| 3616 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 3617 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) |
| 3617 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) | 3618 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) |
| 3619 | |
| 3620 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ic_age, kICAgeOffset) | |
| 3621 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, | |
| 3622 opt_reenable_tries, | |
| 3623 kOptReenableTriesOffset) | |
| 3618 #endif | 3624 #endif |
| 3619 | 3625 |
| 3620 | 3626 |
| 3621 int SharedFunctionInfo::construction_count() { | 3627 int SharedFunctionInfo::construction_count() { |
| 3622 return READ_BYTE_FIELD(this, kConstructionCountOffset); | 3628 return READ_BYTE_FIELD(this, kConstructionCountOffset); |
| 3623 } | 3629 } |
| 3624 | 3630 |
| 3625 | 3631 |
| 3626 void SharedFunctionInfo::set_construction_count(int value) { | 3632 void SharedFunctionInfo::set_construction_count(int value) { |
| 3627 ASSERT(0 <= value && value < 256); | 3633 ASSERT(0 <= value && value < 256); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3647 | 3653 |
| 3648 | 3654 |
| 3649 void SharedFunctionInfo::set_optimization_disabled(bool disable) { | 3655 void SharedFunctionInfo::set_optimization_disabled(bool disable) { |
| 3650 set_compiler_hints(BooleanBit::set(compiler_hints(), | 3656 set_compiler_hints(BooleanBit::set(compiler_hints(), |
| 3651 kOptimizationDisabled, | 3657 kOptimizationDisabled, |
| 3652 disable)); | 3658 disable)); |
| 3653 // If disabling optimizations we reflect that in the code object so | 3659 // If disabling optimizations we reflect that in the code object so |
| 3654 // it will not be counted as optimizable code. | 3660 // it will not be counted as optimizable code. |
| 3655 if ((code()->kind() == Code::FUNCTION) && disable) { | 3661 if ((code()->kind() == Code::FUNCTION) && disable) { |
| 3656 code()->set_optimizable(false); | 3662 code()->set_optimizable(false); |
| 3663 code()->set_profiler_ticks(0); | |
| 3657 } | 3664 } |
| 3658 } | 3665 } |
| 3659 | 3666 |
| 3660 | 3667 |
| 3661 LanguageMode SharedFunctionInfo::language_mode() { | 3668 LanguageMode SharedFunctionInfo::language_mode() { |
| 3662 int hints = compiler_hints(); | 3669 int hints = compiler_hints(); |
| 3663 if (BooleanBit::get(hints, kExtendedModeFunction)) { | 3670 if (BooleanBit::get(hints, kExtendedModeFunction)) { |
| 3664 ASSERT(BooleanBit::get(hints, kStrictModeFunction)); | 3671 ASSERT(BooleanBit::get(hints, kStrictModeFunction)); |
| 3665 return EXTENDED_MODE; | 3672 return EXTENDED_MODE; |
| 3666 } | 3673 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3682 hints = BooleanBit::set( | 3689 hints = BooleanBit::set( |
| 3683 hints, kExtendedModeFunction, language_mode == EXTENDED_MODE); | 3690 hints, kExtendedModeFunction, language_mode == EXTENDED_MODE); |
| 3684 set_compiler_hints(hints); | 3691 set_compiler_hints(hints); |
| 3685 } | 3692 } |
| 3686 | 3693 |
| 3687 | 3694 |
| 3688 bool SharedFunctionInfo::is_classic_mode() { | 3695 bool SharedFunctionInfo::is_classic_mode() { |
| 3689 return !BooleanBit::get(compiler_hints(), kStrictModeFunction); | 3696 return !BooleanBit::get(compiler_hints(), kStrictModeFunction); |
| 3690 } | 3697 } |
| 3691 | 3698 |
| 3699 | |
| 3700 void SharedFunctionInfo::TryReenableOptimization() { | |
| 3701 int tries = opt_reenable_tries(); | |
| 3702 if (tries == Smi::kMaxValue) { | |
| 3703 tries = 0; | |
| 3704 } | |
| 3705 set_opt_reenable_tries(tries + 1); | |
| 3706 // We reenable optimization whenever the number of tries is a large | |
| 3707 // enough power of 2. | |
| 3708 if (tries > 4 && (((tries - 1) & tries) == 0)) { | |
|
Jakob Kummerow
2012/04/24 10:38:22
nit: did you mean ">= 4"?
ulan
2012/04/24 12:36:08
Yes, that's what I meant. :)
Performance on our be
| |
| 3709 set_optimization_disabled(false); | |
| 3710 set_opt_count(0); | |
| 3711 code()->set_optimizable(true); | |
| 3712 } | |
| 3713 } | |
| 3714 | |
| 3715 | |
| 3692 BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode, | 3716 BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode, |
| 3693 kExtendedModeFunction) | 3717 kExtendedModeFunction) |
| 3694 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) | 3718 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) |
| 3695 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, | 3719 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, |
| 3696 name_should_print_as_anonymous, | 3720 name_should_print_as_anonymous, |
| 3697 kNameShouldPrintAsAnonymous) | 3721 kNameShouldPrintAsAnonymous) |
| 3698 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, bound, kBoundFunction) | 3722 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, bound, kBoundFunction) |
| 3699 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) | 3723 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) |
| 3700 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction) | 3724 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction) |
| 3701 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_optimize, | 3725 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_optimize, |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4942 #undef WRITE_UINT32_FIELD | 4966 #undef WRITE_UINT32_FIELD |
| 4943 #undef READ_SHORT_FIELD | 4967 #undef READ_SHORT_FIELD |
| 4944 #undef WRITE_SHORT_FIELD | 4968 #undef WRITE_SHORT_FIELD |
| 4945 #undef READ_BYTE_FIELD | 4969 #undef READ_BYTE_FIELD |
| 4946 #undef WRITE_BYTE_FIELD | 4970 #undef WRITE_BYTE_FIELD |
| 4947 | 4971 |
| 4948 | 4972 |
| 4949 } } // namespace v8::internal | 4973 } } // namespace v8::internal |
| 4950 | 4974 |
| 4951 #endif // V8_OBJECTS_INL_H_ | 4975 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |