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 4156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4167 for (int g = kGroupCount - 1; g > group; g--) { | 4167 for (int g = kGroupCount - 1; g > group; g--) { |
4168 if (starts.at(g) < starts.at(g + 1)) { | 4168 if (starts.at(g) < starts.at(g + 1)) { |
4169 copy(starts.at(g), starts.at(g + 1)); | 4169 copy(starts.at(g), starts.at(g + 1)); |
4170 } | 4170 } |
4171 } | 4171 } |
4172 } | 4172 } |
4173 | 4173 |
4174 | 4174 |
4175 void Code::set_flags(Code::Flags flags) { | 4175 void Code::set_flags(Code::Flags flags) { |
4176 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); | 4176 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); |
4177 // Make sure that all call stubs have an arguments count. | |
4178 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && | |
4179 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || | |
4180 ExtractArgumentsCountFromFlags(flags) >= 0); | |
4181 WRITE_INT_FIELD(this, kFlagsOffset, flags); | 4177 WRITE_INT_FIELD(this, kFlagsOffset, flags); |
4182 } | 4178 } |
4183 | 4179 |
4184 | 4180 |
4185 Code::Kind Code::kind() { | 4181 Code::Kind Code::kind() { |
4186 return ExtractKindFromFlags(flags()); | 4182 return ExtractKindFromFlags(flags()); |
4187 } | 4183 } |
4188 | 4184 |
4189 | 4185 |
4190 InlineCacheState Code::ic_state() { | 4186 InlineCacheState Code::ic_state() { |
(...skipping 21 matching lines...) Expand all Loading... |
4212 return ExtractExtendedExtraICStateFromFlags(flags()); | 4208 return ExtractExtendedExtraICStateFromFlags(flags()); |
4213 } | 4209 } |
4214 | 4210 |
4215 | 4211 |
4216 Code::StubType Code::type() { | 4212 Code::StubType Code::type() { |
4217 return ExtractTypeFromFlags(flags()); | 4213 return ExtractTypeFromFlags(flags()); |
4218 } | 4214 } |
4219 | 4215 |
4220 | 4216 |
4221 int Code::arguments_count() { | 4217 int Code::arguments_count() { |
4222 ASSERT(is_call_stub() || is_keyed_call_stub() || | 4218 ASSERT(kind() == STUB || is_handler()); |
4223 kind() == STUB || is_handler()); | |
4224 return ExtractArgumentsCountFromFlags(flags()); | 4219 return ExtractArgumentsCountFromFlags(flags()); |
4225 } | 4220 } |
4226 | 4221 |
4227 | 4222 |
4228 // For initialization. | 4223 // For initialization. |
4229 void Code::set_raw_kind_specific_flags1(int value) { | 4224 void Code::set_raw_kind_specific_flags1(int value) { |
4230 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); | 4225 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); |
4231 } | 4226 } |
4232 | 4227 |
4233 | 4228 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4268 bool Code::has_major_key() { | 4263 bool Code::has_major_key() { |
4269 return kind() == STUB || | 4264 return kind() == STUB || |
4270 kind() == HANDLER || | 4265 kind() == HANDLER || |
4271 kind() == BINARY_OP_IC || | 4266 kind() == BINARY_OP_IC || |
4272 kind() == COMPARE_IC || | 4267 kind() == COMPARE_IC || |
4273 kind() == COMPARE_NIL_IC || | 4268 kind() == COMPARE_NIL_IC || |
4274 kind() == LOAD_IC || | 4269 kind() == LOAD_IC || |
4275 kind() == KEYED_LOAD_IC || | 4270 kind() == KEYED_LOAD_IC || |
4276 kind() == STORE_IC || | 4271 kind() == STORE_IC || |
4277 kind() == KEYED_STORE_IC || | 4272 kind() == KEYED_STORE_IC || |
4278 kind() == KEYED_CALL_IC || | |
4279 kind() == TO_BOOLEAN_IC; | 4273 kind() == TO_BOOLEAN_IC; |
4280 } | 4274 } |
4281 | 4275 |
4282 | 4276 |
4283 bool Code::optimizable() { | 4277 bool Code::optimizable() { |
4284 ASSERT_EQ(FUNCTION, kind()); | 4278 ASSERT_EQ(FUNCTION, kind()); |
4285 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; | 4279 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; |
4286 } | 4280 } |
4287 | 4281 |
4288 | 4282 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4421 | 4415 |
4422 void Code::set_back_edges_patched_for_osr(bool value) { | 4416 void Code::set_back_edges_patched_for_osr(bool value) { |
4423 ASSERT_EQ(FUNCTION, kind()); | 4417 ASSERT_EQ(FUNCTION, kind()); |
4424 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4418 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
4425 int updated = BackEdgesPatchedForOSRField::update(previous, value); | 4419 int updated = BackEdgesPatchedForOSRField::update(previous, value); |
4426 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4420 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
4427 } | 4421 } |
4428 | 4422 |
4429 | 4423 |
4430 | 4424 |
4431 CheckType Code::check_type() { | |
4432 ASSERT(is_call_stub() || is_keyed_call_stub()); | |
4433 byte type = READ_BYTE_FIELD(this, kCheckTypeOffset); | |
4434 return static_cast<CheckType>(type); | |
4435 } | |
4436 | |
4437 | |
4438 void Code::set_check_type(CheckType value) { | |
4439 ASSERT(is_call_stub() || is_keyed_call_stub()); | |
4440 WRITE_BYTE_FIELD(this, kCheckTypeOffset, value); | |
4441 } | |
4442 | |
4443 | |
4444 byte Code::to_boolean_state() { | 4425 byte Code::to_boolean_state() { |
4445 return extended_extra_ic_state(); | 4426 return extended_extra_ic_state(); |
4446 } | 4427 } |
4447 | 4428 |
4448 | 4429 |
4449 bool Code::has_function_cache() { | 4430 bool Code::has_function_cache() { |
4450 ASSERT(kind() == STUB); | 4431 ASSERT(kind() == STUB); |
4451 return HasFunctionCacheField::decode( | 4432 return HasFunctionCacheField::decode( |
4452 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4433 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
4453 } | 4434 } |
(...skipping 27 matching lines...) Expand all Loading... |
4481 switch (kind) { | 4462 switch (kind) { |
4482 #define CASE(name) case name: return true; | 4463 #define CASE(name) case name: return true; |
4483 IC_KIND_LIST(CASE) | 4464 IC_KIND_LIST(CASE) |
4484 #undef CASE | 4465 #undef CASE |
4485 default: return false; | 4466 default: return false; |
4486 } | 4467 } |
4487 } | 4468 } |
4488 | 4469 |
4489 | 4470 |
4490 bool Code::is_keyed_stub() { | 4471 bool Code::is_keyed_stub() { |
4491 return is_keyed_load_stub() || is_keyed_store_stub() || is_keyed_call_stub(); | 4472 return is_keyed_load_stub() || is_keyed_store_stub(); |
4492 } | 4473 } |
4493 | 4474 |
4494 | 4475 |
4495 bool Code::is_debug_stub() { | 4476 bool Code::is_debug_stub() { |
4496 return ic_state() == DEBUG_STUB; | 4477 return ic_state() == DEBUG_STUB; |
4497 } | 4478 } |
4498 | 4479 |
4499 | 4480 |
4500 ConstantPoolArray* Code::constant_pool() { | 4481 ConstantPoolArray* Code::constant_pool() { |
4501 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); | 4482 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); |
4502 } | 4483 } |
4503 | 4484 |
4504 | 4485 |
4505 void Code::set_constant_pool(Object* value) { | 4486 void Code::set_constant_pool(Object* value) { |
4506 ASSERT(value->IsConstantPoolArray()); | 4487 ASSERT(value->IsConstantPoolArray()); |
4507 WRITE_FIELD(this, kConstantPoolOffset, value); | 4488 WRITE_FIELD(this, kConstantPoolOffset, value); |
4508 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); | 4489 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); |
4509 } | 4490 } |
4510 | 4491 |
4511 | 4492 |
4512 Code::Flags Code::ComputeFlags(Kind kind, | 4493 Code::Flags Code::ComputeFlags(Kind kind, |
4513 InlineCacheState ic_state, | 4494 InlineCacheState ic_state, |
4514 ExtraICState extra_ic_state, | 4495 ExtraICState extra_ic_state, |
4515 StubType type, | 4496 StubType type, |
4516 int argc, | 4497 int argc, |
4517 InlineCacheHolderFlag holder) { | 4498 InlineCacheHolderFlag holder) { |
4518 ASSERT(argc <= Code::kMaxArguments); | 4499 ASSERT(argc <= Code::kMaxArguments); |
4519 // Since the extended extra ic state overlaps with the argument count | |
4520 // for CALL_ICs, do so checks to make sure that they don't interfere. | |
4521 ASSERT((kind != Code::CALL_IC && | |
4522 kind != Code::KEYED_CALL_IC) || | |
4523 (ExtraICStateField::encode(extra_ic_state) | true)); | |
4524 // Compute the bit mask. | 4500 // Compute the bit mask. |
4525 unsigned int bits = KindField::encode(kind) | 4501 unsigned int bits = KindField::encode(kind) |
4526 | ICStateField::encode(ic_state) | 4502 | ICStateField::encode(ic_state) |
4527 | TypeField::encode(type) | 4503 | TypeField::encode(type) |
4528 | ExtendedExtraICStateField::encode(extra_ic_state) | 4504 | ExtendedExtraICStateField::encode(extra_ic_state) |
4529 | CacheHolderField::encode(holder); | 4505 | CacheHolderField::encode(holder); |
4530 if (!Code::needs_extended_extra_ic_state(kind)) { | 4506 if (!Code::needs_extended_extra_ic_state(kind)) { |
4531 bits |= (argc << kArgumentsCountShift); | 4507 bits |= (argc << kArgumentsCountShift); |
4532 } | 4508 } |
4533 return static_cast<Flags>(bits); | 4509 return static_cast<Flags>(bits); |
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6805 #undef READ_UINT32_FIELD | 6781 #undef READ_UINT32_FIELD |
6806 #undef WRITE_UINT32_FIELD | 6782 #undef WRITE_UINT32_FIELD |
6807 #undef READ_SHORT_FIELD | 6783 #undef READ_SHORT_FIELD |
6808 #undef WRITE_SHORT_FIELD | 6784 #undef WRITE_SHORT_FIELD |
6809 #undef READ_BYTE_FIELD | 6785 #undef READ_BYTE_FIELD |
6810 #undef WRITE_BYTE_FIELD | 6786 #undef WRITE_BYTE_FIELD |
6811 | 6787 |
6812 } } // namespace v8::internal | 6788 } } // namespace v8::internal |
6813 | 6789 |
6814 #endif // V8_OBJECTS_INL_H_ | 6790 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |