| 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 2849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2860 READ_FIELD(this, kPrototypeTransitionsOffset)); | 2860 READ_FIELD(this, kPrototypeTransitionsOffset)); |
| 2861 } | 2861 } |
| 2862 | 2862 |
| 2863 | 2863 |
| 2864 Code::Flags Code::flags() { | 2864 Code::Flags Code::flags() { |
| 2865 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); | 2865 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); |
| 2866 } | 2866 } |
| 2867 | 2867 |
| 2868 | 2868 |
| 2869 void Code::set_flags(Code::Flags flags) { | 2869 void Code::set_flags(Code::Flags flags) { |
| 2870 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= (kFlagsKindMask >> kFlagsKindShift)+1); | 2870 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); |
| 2871 // Make sure that all call stubs have an arguments count. | 2871 // Make sure that all call stubs have an arguments count. |
| 2872 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && | 2872 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && |
| 2873 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || | 2873 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || |
| 2874 ExtractArgumentsCountFromFlags(flags) >= 0); | 2874 ExtractArgumentsCountFromFlags(flags) >= 0); |
| 2875 WRITE_INT_FIELD(this, kFlagsOffset, flags); | 2875 WRITE_INT_FIELD(this, kFlagsOffset, flags); |
| 2876 } | 2876 } |
| 2877 | 2877 |
| 2878 | 2878 |
| 2879 Code::Kind Code::kind() { | 2879 Code::Kind Code::kind() { |
| 2880 return ExtractKindFromFlags(flags()); | 2880 return ExtractKindFromFlags(flags()); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3097 PropertyType type, | 3097 PropertyType type, |
| 3098 int argc, | 3098 int argc, |
| 3099 InlineCacheHolderFlag holder) { | 3099 InlineCacheHolderFlag holder) { |
| 3100 // Extra IC state is only allowed for call IC stubs or for store IC | 3100 // Extra IC state is only allowed for call IC stubs or for store IC |
| 3101 // stubs. | 3101 // stubs. |
| 3102 ASSERT(extra_ic_state == kNoExtraICState || | 3102 ASSERT(extra_ic_state == kNoExtraICState || |
| 3103 (kind == CALL_IC) || | 3103 (kind == CALL_IC) || |
| 3104 (kind == STORE_IC) || | 3104 (kind == STORE_IC) || |
| 3105 (kind == KEYED_STORE_IC)); | 3105 (kind == KEYED_STORE_IC)); |
| 3106 // Compute the bit mask. | 3106 // Compute the bit mask. |
| 3107 int bits = kind << kFlagsKindShift; | 3107 int bits = KindField::encode(kind) |
| 3108 if (in_loop) bits |= kFlagsICInLoopMask; | 3108 | ICInLoopField::encode(in_loop) |
| 3109 bits |= ic_state << kFlagsICStateShift; | 3109 | ICStateField::encode(ic_state) |
| 3110 bits |= type << kFlagsTypeShift; | 3110 | TypeField::encode(type) |
| 3111 bits |= extra_ic_state << kFlagsExtraICStateShift; | 3111 | ExtraICStateField::encode(extra_ic_state) |
| 3112 bits |= argc << kFlagsArgumentsCountShift; | 3112 | (argc << kFlagsArgumentsCountShift) |
| 3113 if (holder == PROTOTYPE_MAP) bits |= kFlagsCacheInPrototypeMapMask; | 3113 | CacheHolderField::encode(holder); |
| 3114 // Cast to flags and validate result before returning it. | 3114 return static_cast<Flags>(bits); |
| 3115 Flags result = static_cast<Flags>(bits); | |
| 3116 ASSERT(ExtractKindFromFlags(result) == kind); | |
| 3117 ASSERT(ExtractICStateFromFlags(result) == ic_state); | |
| 3118 ASSERT(ExtractICInLoopFromFlags(result) == in_loop); | |
| 3119 ASSERT(ExtractTypeFromFlags(result) == type); | |
| 3120 ASSERT(ExtractExtraICStateFromFlags(result) == extra_ic_state); | |
| 3121 ASSERT(ExtractArgumentsCountFromFlags(result) == argc); | |
| 3122 return result; | |
| 3123 } | 3115 } |
| 3124 | 3116 |
| 3125 | 3117 |
| 3126 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, | 3118 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, |
| 3127 PropertyType type, | 3119 PropertyType type, |
| 3128 ExtraICState extra_ic_state, | 3120 ExtraICState extra_ic_state, |
| 3129 InlineCacheHolderFlag holder, | 3121 InlineCacheHolderFlag holder, |
| 3130 InLoopFlag in_loop, | 3122 InLoopFlag in_loop, |
| 3131 int argc) { | 3123 int argc) { |
| 3132 return ComputeFlags( | 3124 return ComputeFlags( |
| 3133 kind, in_loop, MONOMORPHIC, extra_ic_state, type, argc, holder); | 3125 kind, in_loop, MONOMORPHIC, extra_ic_state, type, argc, holder); |
| 3134 } | 3126 } |
| 3135 | 3127 |
| 3136 | 3128 |
| 3137 Code::Kind Code::ExtractKindFromFlags(Flags flags) { | 3129 Code::Kind Code::ExtractKindFromFlags(Flags flags) { |
| 3138 int bits = (flags & kFlagsKindMask) >> kFlagsKindShift; | 3130 return KindField::decode(flags); |
| 3139 return static_cast<Kind>(bits); | |
| 3140 } | 3131 } |
| 3141 | 3132 |
| 3142 | 3133 |
| 3143 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { | 3134 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { |
| 3144 int bits = (flags & kFlagsICStateMask) >> kFlagsICStateShift; | 3135 return ICStateField::decode(flags); |
| 3145 return static_cast<InlineCacheState>(bits); | |
| 3146 } | 3136 } |
| 3147 | 3137 |
| 3148 | 3138 |
| 3149 Code::ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { | 3139 Code::ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { |
| 3150 int bits = (flags & kFlagsExtraICStateMask) >> kFlagsExtraICStateShift; | 3140 return ExtraICStateField::decode(flags); |
| 3151 return static_cast<ExtraICState>(bits); | |
| 3152 } | 3141 } |
| 3153 | 3142 |
| 3154 | 3143 |
| 3155 InLoopFlag Code::ExtractICInLoopFromFlags(Flags flags) { | 3144 InLoopFlag Code::ExtractICInLoopFromFlags(Flags flags) { |
| 3156 int bits = (flags & kFlagsICInLoopMask); | 3145 return ICInLoopField::decode(flags); |
| 3157 return bits != 0 ? IN_LOOP : NOT_IN_LOOP; | |
| 3158 } | 3146 } |
| 3159 | 3147 |
| 3160 | 3148 |
| 3161 PropertyType Code::ExtractTypeFromFlags(Flags flags) { | 3149 PropertyType Code::ExtractTypeFromFlags(Flags flags) { |
| 3162 int bits = (flags & kFlagsTypeMask) >> kFlagsTypeShift; | 3150 return TypeField::decode(flags); |
| 3163 return static_cast<PropertyType>(bits); | |
| 3164 } | 3151 } |
| 3165 | 3152 |
| 3166 | 3153 |
| 3167 int Code::ExtractArgumentsCountFromFlags(Flags flags) { | 3154 int Code::ExtractArgumentsCountFromFlags(Flags flags) { |
| 3168 return (flags & kFlagsArgumentsCountMask) >> kFlagsArgumentsCountShift; | 3155 return (flags & kFlagsArgumentsCountMask) >> kFlagsArgumentsCountShift; |
| 3169 } | 3156 } |
| 3170 | 3157 |
| 3171 | 3158 |
| 3172 InlineCacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) { | 3159 InlineCacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) { |
| 3173 int bits = (flags & kFlagsCacheInPrototypeMapMask); | 3160 return CacheHolderField::decode(flags); |
| 3174 return bits != 0 ? PROTOTYPE_MAP : OWN_MAP; | |
| 3175 } | 3161 } |
| 3176 | 3162 |
| 3177 | 3163 |
| 3178 Code::Flags Code::RemoveTypeFromFlags(Flags flags) { | 3164 Code::Flags Code::RemoveTypeFromFlags(Flags flags) { |
| 3179 int bits = flags & ~kFlagsTypeMask; | 3165 int bits = flags & ~TypeField::kMask; |
| 3180 return static_cast<Flags>(bits); | 3166 return static_cast<Flags>(bits); |
| 3181 } | 3167 } |
| 3182 | 3168 |
| 3183 | 3169 |
| 3184 Code* Code::GetCodeFromTargetAddress(Address address) { | 3170 Code* Code::GetCodeFromTargetAddress(Address address) { |
| 3185 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); | 3171 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); |
| 3186 // GetCodeFromTargetAddress might be called when marking objects during mark | 3172 // GetCodeFromTargetAddress might be called when marking objects during mark |
| 3187 // sweep. reinterpret_cast is therefore used instead of the more appropriate | 3173 // sweep. reinterpret_cast is therefore used instead of the more appropriate |
| 3188 // Code::cast. Code::cast does not work when the object's map is | 3174 // Code::cast. Code::cast does not work when the object's map is |
| 3189 // marked. | 3175 // marked. |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4430 set_flag(BooleanBit::set(flag(), kProhibitsOverwritingBit, value)); | 4416 set_flag(BooleanBit::set(flag(), kProhibitsOverwritingBit, value)); |
| 4431 } | 4417 } |
| 4432 | 4418 |
| 4433 | 4419 |
| 4434 PropertyAttributes AccessorInfo::property_attributes() { | 4420 PropertyAttributes AccessorInfo::property_attributes() { |
| 4435 return AttributesField::decode(static_cast<uint32_t>(flag()->value())); | 4421 return AttributesField::decode(static_cast<uint32_t>(flag()->value())); |
| 4436 } | 4422 } |
| 4437 | 4423 |
| 4438 | 4424 |
| 4439 void AccessorInfo::set_property_attributes(PropertyAttributes attributes) { | 4425 void AccessorInfo::set_property_attributes(PropertyAttributes attributes) { |
| 4440 ASSERT(AttributesField::is_valid(attributes)); | 4426 set_flag(Smi::FromInt(AttributesField::update(flag()->value(), attributes))); |
| 4441 int rest_value = flag()->value() & ~AttributesField::mask(); | |
| 4442 set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes))); | |
| 4443 } | 4427 } |
| 4444 | 4428 |
| 4445 | 4429 |
| 4446 template<typename Shape, typename Key> | 4430 template<typename Shape, typename Key> |
| 4447 void Dictionary<Shape, Key>::SetEntry(int entry, | 4431 void Dictionary<Shape, Key>::SetEntry(int entry, |
| 4448 Object* key, | 4432 Object* key, |
| 4449 Object* value) { | 4433 Object* value) { |
| 4450 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); | 4434 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
| 4451 } | 4435 } |
| 4452 | 4436 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4685 #undef WRITE_INT_FIELD | 4669 #undef WRITE_INT_FIELD |
| 4686 #undef READ_SHORT_FIELD | 4670 #undef READ_SHORT_FIELD |
| 4687 #undef WRITE_SHORT_FIELD | 4671 #undef WRITE_SHORT_FIELD |
| 4688 #undef READ_BYTE_FIELD | 4672 #undef READ_BYTE_FIELD |
| 4689 #undef WRITE_BYTE_FIELD | 4673 #undef WRITE_BYTE_FIELD |
| 4690 | 4674 |
| 4691 | 4675 |
| 4692 } } // namespace v8::internal | 4676 } } // namespace v8::internal |
| 4693 | 4677 |
| 4694 #endif // V8_OBJECTS_INL_H_ | 4678 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |