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 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3045 return ExtractArgumentsCountFromFlags(flags()); | 3045 return ExtractArgumentsCountFromFlags(flags()); |
3046 } | 3046 } |
3047 | 3047 |
3048 | 3048 |
3049 int Code::major_key() { | 3049 int Code::major_key() { |
3050 ASSERT(kind() == STUB || | 3050 ASSERT(kind() == STUB || |
3051 kind() == UNARY_OP_IC || | 3051 kind() == UNARY_OP_IC || |
3052 kind() == BINARY_OP_IC || | 3052 kind() == BINARY_OP_IC || |
3053 kind() == COMPARE_IC || | 3053 kind() == COMPARE_IC || |
3054 kind() == TO_BOOLEAN_IC); | 3054 kind() == TO_BOOLEAN_IC); |
3055 return READ_BYTE_FIELD(this, kStubMajorKeyOffset); | 3055 return StubMajorKeyField::decode( |
3056 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3056 } | 3057 } |
3057 | 3058 |
3058 | 3059 |
3059 void Code::set_major_key(int major) { | 3060 void Code::set_major_key(int major) { |
3060 ASSERT(kind() == STUB || | 3061 ASSERT(kind() == STUB || |
3061 kind() == UNARY_OP_IC || | 3062 kind() == UNARY_OP_IC || |
3062 kind() == BINARY_OP_IC || | 3063 kind() == BINARY_OP_IC || |
3063 kind() == COMPARE_IC || | 3064 kind() == COMPARE_IC || |
3064 kind() == TO_BOOLEAN_IC); | 3065 kind() == TO_BOOLEAN_IC); |
3065 ASSERT(0 <= major && major < 256); | 3066 ASSERT(0 <= major && major < 256); |
3066 WRITE_BYTE_FIELD(this, kStubMajorKeyOffset, major); | 3067 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3068 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, | |
3069 StubMajorKeyField::update(previous, major)); | |
Michael Starzinger
2012/07/06 16:22:19
Indentation seems off. Can we also pull this out i
danno
2012/07/06 16:36:00
Done.
| |
3067 } | 3070 } |
3068 | 3071 |
3069 | 3072 |
3070 bool Code::is_pregenerated() { | 3073 bool Code::is_pregenerated() { |
3071 return kind() == STUB && IsPregeneratedField::decode(flags()); | 3074 return kind() == STUB && IsPregeneratedField::decode(flags()); |
3072 } | 3075 } |
3073 | 3076 |
3074 | 3077 |
3075 void Code::set_is_pregenerated(bool value) { | 3078 void Code::set_is_pregenerated(bool value) { |
3076 ASSERT(kind() == STUB); | 3079 ASSERT(kind() == STUB); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3158 | 3161 |
3159 void Code::set_profiler_ticks(int ticks) { | 3162 void Code::set_profiler_ticks(int ticks) { |
3160 ASSERT_EQ(FUNCTION, kind()); | 3163 ASSERT_EQ(FUNCTION, kind()); |
3161 ASSERT(ticks < 256); | 3164 ASSERT(ticks < 256); |
3162 WRITE_BYTE_FIELD(this, kProfilerTicksOffset, ticks); | 3165 WRITE_BYTE_FIELD(this, kProfilerTicksOffset, ticks); |
3163 } | 3166 } |
3164 | 3167 |
3165 | 3168 |
3166 unsigned Code::stack_slots() { | 3169 unsigned Code::stack_slots() { |
3167 ASSERT(kind() == OPTIMIZED_FUNCTION); | 3170 ASSERT(kind() == OPTIMIZED_FUNCTION); |
3168 return READ_UINT32_FIELD(this, kStackSlotsOffset); | 3171 return StackSlotsField::decode( |
3172 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3169 } | 3173 } |
3170 | 3174 |
3171 | 3175 |
3172 void Code::set_stack_slots(unsigned slots) { | 3176 void Code::set_stack_slots(unsigned slots) { |
3177 CHECK(slots <= (1 << kStackSlotsBitCount)); | |
3173 ASSERT(kind() == OPTIMIZED_FUNCTION); | 3178 ASSERT(kind() == OPTIMIZED_FUNCTION); |
3174 WRITE_UINT32_FIELD(this, kStackSlotsOffset, slots); | 3179 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3180 int updated = StackSlotsField::update(previous, slots); | |
3181 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3175 } | 3182 } |
3176 | 3183 |
3177 | 3184 |
3178 unsigned Code::safepoint_table_offset() { | 3185 unsigned Code::safepoint_table_offset() { |
3179 ASSERT(kind() == OPTIMIZED_FUNCTION); | 3186 ASSERT(kind() == OPTIMIZED_FUNCTION); |
3180 return READ_UINT32_FIELD(this, kSafepointTableOffsetOffset); | 3187 return SafepointTableOffsetField::decode( |
3188 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)); | |
3181 } | 3189 } |
3182 | 3190 |
3183 | 3191 |
3184 void Code::set_safepoint_table_offset(unsigned offset) { | 3192 void Code::set_safepoint_table_offset(unsigned offset) { |
3193 CHECK(offset <= (1 << kSafepointTableOffsetBitCount)); | |
3185 ASSERT(kind() == OPTIMIZED_FUNCTION); | 3194 ASSERT(kind() == OPTIMIZED_FUNCTION); |
3186 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); | 3195 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); |
3187 WRITE_UINT32_FIELD(this, kSafepointTableOffsetOffset, offset); | 3196 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
3197 int updated = SafepointTableOffsetField::update(previous, offset); | |
3198 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | |
3188 } | 3199 } |
3189 | 3200 |
3190 | 3201 |
3191 unsigned Code::stack_check_table_offset() { | 3202 unsigned Code::stack_check_table_offset() { |
3192 ASSERT_EQ(FUNCTION, kind()); | 3203 ASSERT_EQ(FUNCTION, kind()); |
3193 return READ_UINT32_FIELD(this, kStackCheckTableOffsetOffset); | 3204 return StackCheckTableOffsetField::decode( |
3205 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)); | |
3194 } | 3206 } |
3195 | 3207 |
3196 | 3208 |
3197 void Code::set_stack_check_table_offset(unsigned offset) { | 3209 void Code::set_stack_check_table_offset(unsigned offset) { |
3198 ASSERT_EQ(FUNCTION, kind()); | 3210 ASSERT_EQ(FUNCTION, kind()); |
3199 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); | 3211 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); |
3200 WRITE_UINT32_FIELD(this, kStackCheckTableOffsetOffset, offset); | 3212 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
3213 int updated = StackCheckTableOffsetField::update(previous, offset); | |
3214 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | |
3201 } | 3215 } |
3202 | 3216 |
3203 | 3217 |
3204 CheckType Code::check_type() { | 3218 CheckType Code::check_type() { |
3205 ASSERT(is_call_stub() || is_keyed_call_stub()); | 3219 ASSERT(is_call_stub() || is_keyed_call_stub()); |
3206 byte type = READ_BYTE_FIELD(this, kCheckTypeOffset); | 3220 byte type = READ_BYTE_FIELD(this, kCheckTypeOffset); |
3207 return static_cast<CheckType>(type); | 3221 return static_cast<CheckType>(type); |
3208 } | 3222 } |
3209 | 3223 |
3210 | 3224 |
3211 void Code::set_check_type(CheckType value) { | 3225 void Code::set_check_type(CheckType value) { |
3212 ASSERT(is_call_stub() || is_keyed_call_stub()); | 3226 ASSERT(is_call_stub() || is_keyed_call_stub()); |
3213 WRITE_BYTE_FIELD(this, kCheckTypeOffset, value); | 3227 WRITE_BYTE_FIELD(this, kCheckTypeOffset, value); |
3214 } | 3228 } |
3215 | 3229 |
3216 | 3230 |
3217 byte Code::unary_op_type() { | 3231 byte Code::unary_op_type() { |
3218 ASSERT(is_unary_op_stub()); | 3232 ASSERT(is_unary_op_stub()); |
3219 return READ_BYTE_FIELD(this, kUnaryOpTypeOffset); | 3233 return UnaryOpTypeField::decode( |
3234 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3220 } | 3235 } |
3221 | 3236 |
3222 | 3237 |
3223 void Code::set_unary_op_type(byte value) { | 3238 void Code::set_unary_op_type(byte value) { |
3224 ASSERT(is_unary_op_stub()); | 3239 ASSERT(is_unary_op_stub()); |
3225 WRITE_BYTE_FIELD(this, kUnaryOpTypeOffset, value); | 3240 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3241 int updated = UnaryOpTypeField::update(previous, value); | |
3242 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3226 } | 3243 } |
3227 | 3244 |
3228 | 3245 |
3229 byte Code::binary_op_type() { | 3246 byte Code::binary_op_type() { |
3230 ASSERT(is_binary_op_stub()); | 3247 ASSERT(is_binary_op_stub()); |
3231 return READ_BYTE_FIELD(this, kBinaryOpTypeOffset); | 3248 return BinaryOpTypeField::decode( |
3249 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3232 } | 3250 } |
3233 | 3251 |
3234 | 3252 |
3235 void Code::set_binary_op_type(byte value) { | 3253 void Code::set_binary_op_type(byte value) { |
3236 ASSERT(is_binary_op_stub()); | 3254 ASSERT(is_binary_op_stub()); |
3237 WRITE_BYTE_FIELD(this, kBinaryOpTypeOffset, value); | 3255 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3256 int updated = BinaryOpTypeField::update(previous, value); | |
3257 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3238 } | 3258 } |
3239 | 3259 |
3240 | 3260 |
3241 byte Code::binary_op_result_type() { | 3261 byte Code::binary_op_result_type() { |
3242 ASSERT(is_binary_op_stub()); | 3262 ASSERT(is_binary_op_stub()); |
3243 return READ_BYTE_FIELD(this, kBinaryOpReturnTypeOffset); | 3263 return BinaryOpResultTypeField::decode( |
3264 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3244 } | 3265 } |
3245 | 3266 |
3246 | 3267 |
3247 void Code::set_binary_op_result_type(byte value) { | 3268 void Code::set_binary_op_result_type(byte value) { |
3248 ASSERT(is_binary_op_stub()); | 3269 ASSERT(is_binary_op_stub()); |
3249 WRITE_BYTE_FIELD(this, kBinaryOpReturnTypeOffset, value); | 3270 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3271 int updated = BinaryOpResultTypeField::update(previous, value); | |
3272 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3250 } | 3273 } |
3251 | 3274 |
3252 | 3275 |
3253 byte Code::compare_state() { | 3276 byte Code::compare_state() { |
3254 ASSERT(is_compare_ic_stub()); | 3277 ASSERT(is_compare_ic_stub()); |
3255 return READ_BYTE_FIELD(this, kCompareStateOffset); | 3278 return CompareStateField::decode( |
3279 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3256 } | 3280 } |
3257 | 3281 |
3258 | 3282 |
3259 void Code::set_compare_state(byte value) { | 3283 void Code::set_compare_state(byte value) { |
3260 ASSERT(is_compare_ic_stub()); | 3284 ASSERT(is_compare_ic_stub()); |
3261 WRITE_BYTE_FIELD(this, kCompareStateOffset, value); | 3285 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3286 int updated = CompareStateField::update(previous, value); | |
3287 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3262 } | 3288 } |
3263 | 3289 |
3264 | 3290 |
3265 byte Code::compare_operation() { | 3291 byte Code::compare_operation() { |
3266 ASSERT(is_compare_ic_stub()); | 3292 ASSERT(is_compare_ic_stub()); |
3267 return READ_BYTE_FIELD(this, kCompareOperationOffset); | 3293 return CompareOperationField::decode( |
3294 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)) + Token::EQ; | |
Michael Starzinger
2012/07/06 16:22:19
Can we move the addition of Token::EQ into Compare
danno
2012/07/06 16:36:00
Done.
| |
3268 } | 3295 } |
3269 | 3296 |
3270 | 3297 |
3271 void Code::set_compare_operation(byte value) { | 3298 void Code::set_compare_operation(byte value) { |
3272 ASSERT(is_compare_ic_stub()); | 3299 ASSERT(is_compare_ic_stub()); |
3273 WRITE_BYTE_FIELD(this, kCompareOperationOffset, value); | 3300 Token::IsCompareOp(static_cast<Token::Value>(value)); |
Michael Starzinger
2012/07/06 16:22:19
There is probably an ASSERT missing around that ca
danno
2012/07/06 16:36:00
Done.
| |
3301 value -= Token::EQ; | |
Michael Starzinger
2012/07/06 16:22:19
Can we move the substraction of Token::EQ into ICC
danno
2012/07/06 16:36:00
Done.
| |
3302 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | |
3303 int updated = CompareOperationField::update(previous, value); | |
3304 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3274 } | 3305 } |
3275 | 3306 |
3276 | 3307 |
3277 byte Code::to_boolean_state() { | 3308 byte Code::to_boolean_state() { |
3278 ASSERT(is_to_boolean_ic_stub()); | 3309 ASSERT(is_to_boolean_ic_stub()); |
3279 return READ_BYTE_FIELD(this, kToBooleanTypeOffset); | 3310 return ToBooleanStateField::decode( |
3311 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3280 } | 3312 } |
3281 | 3313 |
3282 | 3314 |
3283 void Code::set_to_boolean_state(byte value) { | 3315 void Code::set_to_boolean_state(byte value) { |
3284 ASSERT(is_to_boolean_ic_stub()); | 3316 ASSERT(is_to_boolean_ic_stub()); |
3285 WRITE_BYTE_FIELD(this, kToBooleanTypeOffset, value); | 3317 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3318 int updated = ToBooleanStateField::update(previous, value); | |
3319 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3286 } | 3320 } |
3287 | 3321 |
3288 | 3322 |
3289 bool Code::has_function_cache() { | 3323 bool Code::has_function_cache() { |
3290 ASSERT(kind() == STUB); | 3324 ASSERT(kind() == STUB); |
3291 return READ_BYTE_FIELD(this, kHasFunctionCacheOffset) != 0; | 3325 return HasFunctionCacheField::decode( |
3326 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | |
3292 } | 3327 } |
3293 | 3328 |
3294 | 3329 |
3295 void Code::set_has_function_cache(bool flag) { | 3330 void Code::set_has_function_cache(bool flag) { |
3296 ASSERT(kind() == STUB); | 3331 ASSERT(kind() == STUB); |
3297 WRITE_BYTE_FIELD(this, kHasFunctionCacheOffset, flag); | 3332 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
3333 int updated = HasFunctionCacheField::update(previous, flag); | |
3334 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | |
3298 } | 3335 } |
3299 | 3336 |
3300 | 3337 |
3301 bool Code::is_inline_cache_stub() { | 3338 bool Code::is_inline_cache_stub() { |
3302 Kind kind = this->kind(); | 3339 Kind kind = this->kind(); |
3303 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; | 3340 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; |
3304 } | 3341 } |
3305 | 3342 |
3306 | 3343 |
3307 Code::Flags Code::ComputeFlags(Kind kind, | 3344 Code::Flags Code::ComputeFlags(Kind kind, |
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5280 #undef WRITE_UINT32_FIELD | 5317 #undef WRITE_UINT32_FIELD |
5281 #undef READ_SHORT_FIELD | 5318 #undef READ_SHORT_FIELD |
5282 #undef WRITE_SHORT_FIELD | 5319 #undef WRITE_SHORT_FIELD |
5283 #undef READ_BYTE_FIELD | 5320 #undef READ_BYTE_FIELD |
5284 #undef WRITE_BYTE_FIELD | 5321 #undef WRITE_BYTE_FIELD |
5285 | 5322 |
5286 | 5323 |
5287 } } // namespace v8::internal | 5324 } } // namespace v8::internal |
5288 | 5325 |
5289 #endif // V8_OBJECTS_INL_H_ | 5326 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |