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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 | 1221 |
1222 | 1222 |
1223 void HeapObject::set_map_word(MapWord map_word) { | 1223 void HeapObject::set_map_word(MapWord map_word) { |
1224 // WRITE_FIELD does not invoke write barrier, but there is no need | 1224 // WRITE_FIELD does not invoke write barrier, but there is no need |
1225 // here. | 1225 // here. |
1226 WRITE_FIELD(this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); | 1226 WRITE_FIELD(this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); |
1227 } | 1227 } |
1228 | 1228 |
1229 | 1229 |
1230 HeapObject* HeapObject::FromAddress(Address address) { | 1230 HeapObject* HeapObject::FromAddress(Address address) { |
| 1231 address = (Address)((uint32_t)address & ~1); |
1231 ASSERT_TAG_ALIGNED(address); | 1232 ASSERT_TAG_ALIGNED(address); |
1232 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1233 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
1233 } | 1234 } |
1234 | 1235 |
1235 | 1236 |
1236 Address HeapObject::address() { | 1237 Address HeapObject::address() { |
1237 return reinterpret_cast<Address>(this) - kHeapObjectTag; | 1238 return reinterpret_cast<Address>(this) - kHeapObjectTag; |
1238 } | 1239 } |
1239 | 1240 |
1240 | 1241 |
(...skipping 2622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3863 | 3864 |
3864 | 3865 |
3865 void Code::set_is_pregenerated(bool value) { | 3866 void Code::set_is_pregenerated(bool value) { |
3866 ASSERT(kind() == STUB); | 3867 ASSERT(kind() == STUB); |
3867 Flags f = flags(); | 3868 Flags f = flags(); |
3868 f = static_cast<Flags>(IsPregeneratedField::update(f, value)); | 3869 f = static_cast<Flags>(IsPregeneratedField::update(f, value)); |
3869 set_flags(f); | 3870 set_flags(f); |
3870 } | 3871 } |
3871 | 3872 |
3872 | 3873 |
| 3874 bool Code::is_thumb_mode() { |
| 3875 return IsThumbModeField::decode(flags()); |
| 3876 } |
| 3877 |
| 3878 |
3873 bool Code::optimizable() { | 3879 bool Code::optimizable() { |
3874 ASSERT_EQ(FUNCTION, kind()); | 3880 ASSERT_EQ(FUNCTION, kind()); |
3875 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; | 3881 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; |
3876 } | 3882 } |
3877 | 3883 |
3878 | 3884 |
3879 void Code::set_optimizable(bool value) { | 3885 void Code::set_optimizable(bool value) { |
3880 ASSERT_EQ(FUNCTION, kind()); | 3886 ASSERT_EQ(FUNCTION, kind()); |
3881 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); | 3887 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); |
3882 } | 3888 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4075 default: return false; | 4081 default: return false; |
4076 } | 4082 } |
4077 } | 4083 } |
4078 | 4084 |
4079 | 4085 |
4080 bool Code::is_debug_stub() { | 4086 bool Code::is_debug_stub() { |
4081 return ic_state() == DEBUG_STUB; | 4087 return ic_state() == DEBUG_STUB; |
4082 } | 4088 } |
4083 | 4089 |
4084 | 4090 |
| 4091 Code::Flags Code::SetThumbModeInFlags(Code::Flags flag) { |
| 4092 return static_cast<Flags>(flag | IsThumbModeField::encode(true)); |
| 4093 } |
| 4094 |
| 4095 |
4085 Code::Flags Code::ComputeFlags(Kind kind, | 4096 Code::Flags Code::ComputeFlags(Kind kind, |
4086 InlineCacheState ic_state, | 4097 InlineCacheState ic_state, |
4087 ExtraICState extra_ic_state, | 4098 ExtraICState extra_ic_state, |
4088 StubType type, | 4099 StubType type, |
4089 int argc, | 4100 int argc, |
4090 InlineCacheHolderFlag holder) { | 4101 InlineCacheHolderFlag holder, |
| 4102 bool thumb_mode) { |
4091 ASSERT(argc <= Code::kMaxArguments); | 4103 ASSERT(argc <= Code::kMaxArguments); |
4092 // Since the extended extra ic state overlaps with the argument count | 4104 // Since the extended extra ic state overlaps with the argument count |
4093 // for CALL_ICs, do so checks to make sure that they don't interfere. | 4105 // for CALL_ICs, do so checks to make sure that they don't interfere. |
4094 ASSERT((kind != Code::CALL_IC && | 4106 ASSERT((kind != Code::CALL_IC && |
4095 kind != Code::KEYED_CALL_IC) || | 4107 kind != Code::KEYED_CALL_IC) || |
4096 (ExtraICStateField::encode(extra_ic_state) | true)); | 4108 (ExtraICStateField::encode(extra_ic_state) | true)); |
4097 // Compute the bit mask. | 4109 // Compute the bit mask. |
4098 unsigned int bits = KindField::encode(kind) | 4110 unsigned int bits = KindField::encode(kind) |
4099 | ICStateField::encode(ic_state) | 4111 | ICStateField::encode(ic_state) |
4100 | TypeField::encode(type) | 4112 | TypeField::encode(type) |
4101 | ExtendedExtraICStateField::encode(extra_ic_state) | 4113 | ExtendedExtraICStateField::encode(extra_ic_state) |
4102 | CacheHolderField::encode(holder); | 4114 | CacheHolderField::encode(holder) |
| 4115 | IsThumbModeField::encode(thumb_mode); |
4103 if (!Code::needs_extended_extra_ic_state(kind)) { | 4116 if (!Code::needs_extended_extra_ic_state(kind)) { |
4104 bits |= (argc << kArgumentsCountShift); | 4117 bits |= (argc << kArgumentsCountShift); |
4105 } | 4118 } |
4106 return static_cast<Flags>(bits); | 4119 return static_cast<Flags>(bits); |
4107 } | 4120 } |
4108 | 4121 |
4109 | 4122 |
4110 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, | 4123 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, |
4111 ExtraICState extra_ic_state, | 4124 ExtraICState extra_ic_state, |
4112 StubType type, | 4125 StubType type, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4152 } | 4165 } |
4153 | 4166 |
4154 | 4167 |
4155 Code::Flags Code::RemoveTypeFromFlags(Flags flags) { | 4168 Code::Flags Code::RemoveTypeFromFlags(Flags flags) { |
4156 int bits = flags & ~TypeField::kMask; | 4169 int bits = flags & ~TypeField::kMask; |
4157 return static_cast<Flags>(bits); | 4170 return static_cast<Flags>(bits); |
4158 } | 4171 } |
4159 | 4172 |
4160 | 4173 |
4161 Code* Code::GetCodeFromTargetAddress(Address address) { | 4174 Code* Code::GetCodeFromTargetAddress(Address address) { |
| 4175 address = (Address)((uint32_t)address & ~3); |
4162 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); | 4176 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); |
4163 // GetCodeFromTargetAddress might be called when marking objects during mark | 4177 // GetCodeFromTargetAddress might be called when marking objects during mark |
4164 // sweep. reinterpret_cast is therefore used instead of the more appropriate | 4178 // sweep. reinterpret_cast is therefore used instead of the more appropriate |
4165 // Code::cast. Code::cast does not work when the object's map is | 4179 // Code::cast. Code::cast does not work when the object's map is |
4166 // marked. | 4180 // marked. |
4167 Code* result = reinterpret_cast<Code*>(code); | 4181 Code* result = reinterpret_cast<Code*>(code); |
4168 return result; | 4182 return result; |
4169 } | 4183 } |
4170 | 4184 |
4171 | 4185 |
4172 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { | 4186 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { |
4173 return HeapObject:: | 4187 return HeapObject:: |
4174 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); | 4188 FromAddress( |
| 4189 Memory::Address_at((Address)((uint32_t)location_of_address & ~1)) |
| 4190 - Code::kHeaderSize); |
4175 } | 4191 } |
4176 | 4192 |
4177 | 4193 |
4178 Object* Map::prototype() { | 4194 Object* Map::prototype() { |
4179 return READ_FIELD(this, kPrototypeOffset); | 4195 return READ_FIELD(this, kPrototypeOffset); |
4180 } | 4196 } |
4181 | 4197 |
4182 | 4198 |
4183 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 4199 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
4184 ASSERT(value->IsNull() || value->IsJSReceiver()); | 4200 ASSERT(value->IsNull() || value->IsJSReceiver()); |
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5344 return unchecked_relocation_info()->GetDataStartAddress(); | 5360 return unchecked_relocation_info()->GetDataStartAddress(); |
5345 } | 5361 } |
5346 | 5362 |
5347 | 5363 |
5348 int Code::relocation_size() { | 5364 int Code::relocation_size() { |
5349 return unchecked_relocation_info()->length(); | 5365 return unchecked_relocation_info()->length(); |
5350 } | 5366 } |
5351 | 5367 |
5352 | 5368 |
5353 byte* Code::entry() { | 5369 byte* Code::entry() { |
5354 return instruction_start(); | 5370 int mode_encoding = is_thumb_mode() ? 1 : 0; |
| 5371 return mode_encoding + instruction_start(); |
5355 } | 5372 } |
5356 | 5373 |
5357 | 5374 |
5358 bool Code::contains(byte* inner_pointer) { | 5375 bool Code::contains(byte* inner_pointer) { |
5359 return (address() <= inner_pointer) && (inner_pointer <= address() + Size()); | 5376 return (address() <= inner_pointer) && (inner_pointer <= address() + Size()); |
5360 } | 5377 } |
5361 | 5378 |
5362 | 5379 |
5363 ACCESSORS(JSArray, length, Object, kLengthOffset) | 5380 ACCESSORS(JSArray, length, Object, kLengthOffset) |
5364 | 5381 |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6293 #undef WRITE_UINT32_FIELD | 6310 #undef WRITE_UINT32_FIELD |
6294 #undef READ_SHORT_FIELD | 6311 #undef READ_SHORT_FIELD |
6295 #undef WRITE_SHORT_FIELD | 6312 #undef WRITE_SHORT_FIELD |
6296 #undef READ_BYTE_FIELD | 6313 #undef READ_BYTE_FIELD |
6297 #undef WRITE_BYTE_FIELD | 6314 #undef WRITE_BYTE_FIELD |
6298 | 6315 |
6299 | 6316 |
6300 } } // namespace v8::internal | 6317 } } // namespace v8::internal |
6301 | 6318 |
6302 #endif // V8_OBJECTS_INL_H_ | 6319 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |