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 4134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 static const int kContextHeaderSize = 2 * kApiPointerSize; | 4145 static const int kContextHeaderSize = 2 * kApiPointerSize; |
4146 static const int kContextEmbedderDataIndex = 54; | 4146 static const int kContextEmbedderDataIndex = 54; |
4147 static const int kFullStringRepresentationMask = 0x07; | 4147 static const int kFullStringRepresentationMask = 0x07; |
4148 static const int kStringEncodingMask = 0x4; | 4148 static const int kStringEncodingMask = 0x4; |
4149 static const int kExternalTwoByteRepresentationTag = 0x02; | 4149 static const int kExternalTwoByteRepresentationTag = 0x02; |
4150 static const int kExternalAsciiRepresentationTag = 0x06; | 4150 static const int kExternalAsciiRepresentationTag = 0x06; |
4151 | 4151 |
4152 static const int kIsolateStateOffset = 0; | 4152 static const int kIsolateStateOffset = 0; |
4153 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 4153 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; |
4154 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 4154 static const int kIsolateRootsOffset = 3 * kApiPointerSize; |
| 4155 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; |
4155 static const int kUndefinedValueRootIndex = 5; | 4156 static const int kUndefinedValueRootIndex = 5; |
4156 static const int kNullValueRootIndex = 7; | 4157 static const int kNullValueRootIndex = 7; |
4157 static const int kTrueValueRootIndex = 8; | 4158 static const int kTrueValueRootIndex = 8; |
4158 static const int kFalseValueRootIndex = 9; | 4159 static const int kFalseValueRootIndex = 9; |
4159 static const int kEmptySymbolRootIndex = 119; | 4160 static const int kEmptySymbolRootIndex = 119; |
4160 | 4161 |
| 4162 static const int kNodeIsIndependentShift = 4; |
| 4163 static const int kNodeIsPartiallyDependentShift = 5; |
| 4164 |
4161 static const int kJSObjectType = 0xab; | 4165 static const int kJSObjectType = 0xab; |
4162 static const int kFirstNonstringType = 0x80; | 4166 static const int kFirstNonstringType = 0x80; |
4163 static const int kOddballType = 0x82; | 4167 static const int kOddballType = 0x82; |
4164 static const int kForeignType = 0x85; | 4168 static const int kForeignType = 0x85; |
4165 | 4169 |
4166 static const int kUndefinedOddballKind = 5; | 4170 static const int kUndefinedOddballKind = 5; |
4167 static const int kNullOddballKind = 3; | 4171 static const int kNullOddballKind = 3; |
4168 | 4172 |
4169 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { | 4173 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { |
4170 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 4174 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
(...skipping 18 matching lines...) Expand all Loading... |
4189 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { | 4193 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { |
4190 int representation = (instance_type & kFullStringRepresentationMask); | 4194 int representation = (instance_type & kFullStringRepresentationMask); |
4191 return representation == kExternalTwoByteRepresentationTag; | 4195 return representation == kExternalTwoByteRepresentationTag; |
4192 } | 4196 } |
4193 | 4197 |
4194 V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { | 4198 V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { |
4195 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; | 4199 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; |
4196 return *reinterpret_cast<int*>(addr) == 1; | 4200 return *reinterpret_cast<int*>(addr) == 1; |
4197 } | 4201 } |
4198 | 4202 |
| 4203 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { |
| 4204 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 4205 return *addr & (1 << shift); |
| 4206 } |
| 4207 |
| 4208 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, |
| 4209 bool value, int shift)) { |
| 4210 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 4211 uint8_t mask = 1 << shift; |
| 4212 *addr = (*addr & ~mask) | (value << shift); |
| 4213 } |
| 4214 |
4199 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { | 4215 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { |
4200 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 4216 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
4201 kIsolateEmbedderDataOffset; | 4217 kIsolateEmbedderDataOffset; |
4202 *reinterpret_cast<void**>(addr) = data; | 4218 *reinterpret_cast<void**>(addr) = data; |
4203 } | 4219 } |
4204 | 4220 |
4205 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { | 4221 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { |
4206 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 4222 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
4207 kIsolateEmbedderDataOffset; | 4223 kIsolateEmbedderDataOffset; |
4208 return *reinterpret_cast<void**>(addr); | 4224 return *reinterpret_cast<void**>(addr); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4282 | 4298 |
4283 template <class T> | 4299 template <class T> |
4284 bool Persistent<T>::IsIndependent() const { | 4300 bool Persistent<T>::IsIndependent() const { |
4285 if (this->IsEmpty()) return false; | 4301 if (this->IsEmpty()) return false; |
4286 return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this)); | 4302 return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this)); |
4287 } | 4303 } |
4288 | 4304 |
4289 | 4305 |
4290 template <class T> | 4306 template <class T> |
4291 bool Persistent<T>::IsIndependent(Isolate* isolate) const { | 4307 bool Persistent<T>::IsIndependent(Isolate* isolate) const { |
| 4308 typedef internal::Internals I; |
4292 if (this->IsEmpty()) return false; | 4309 if (this->IsEmpty()) return false; |
4293 return V8::IsGlobalIndependent(reinterpret_cast<internal::Isolate*>(isolate), | 4310 if (!I::IsInitialized(isolate)) return false; |
4294 reinterpret_cast<internal::Object**>(**this)); | 4311 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this), |
| 4312 I::kNodeIsIndependentShift); |
4295 } | 4313 } |
4296 | 4314 |
4297 | 4315 |
4298 template <class T> | 4316 template <class T> |
4299 bool Persistent<T>::IsNearDeath() const { | 4317 bool Persistent<T>::IsNearDeath() const { |
4300 if (this->IsEmpty()) return false; | 4318 if (this->IsEmpty()) return false; |
4301 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); | 4319 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); |
4302 } | 4320 } |
4303 | 4321 |
4304 | 4322 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4356 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); | 4374 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); |
4357 } | 4375 } |
4358 | 4376 |
4359 template <class T> | 4377 template <class T> |
4360 void Persistent<T>::MarkIndependent() { | 4378 void Persistent<T>::MarkIndependent() { |
4361 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); | 4379 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); |
4362 } | 4380 } |
4363 | 4381 |
4364 template <class T> | 4382 template <class T> |
4365 void Persistent<T>::MarkIndependent(Isolate* isolate) { | 4383 void Persistent<T>::MarkIndependent(Isolate* isolate) { |
4366 V8::MarkIndependent(reinterpret_cast<internal::Isolate*>(isolate), | 4384 typedef internal::Internals I; |
4367 reinterpret_cast<internal::Object**>(**this)); | 4385 if (this->IsEmpty()) return; |
| 4386 if (!I::IsInitialized(isolate)) return; |
| 4387 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), |
| 4388 true, I::kNodeIsIndependentShift); |
4368 } | 4389 } |
4369 | 4390 |
4370 template <class T> | 4391 template <class T> |
4371 void Persistent<T>::MarkPartiallyDependent() { | 4392 void Persistent<T>::MarkPartiallyDependent() { |
4372 V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this)); | 4393 V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this)); |
4373 } | 4394 } |
4374 | 4395 |
4375 template <class T> | 4396 template <class T> |
4376 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { | 4397 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { |
4377 V8::MarkPartiallyDependent(reinterpret_cast<internal::Isolate*>(isolate), | 4398 typedef internal::Internals I; |
4378 reinterpret_cast<internal::Object**>(**this)); | 4399 if (this->IsEmpty()) return; |
| 4400 if (!I::IsInitialized(isolate)) return; |
| 4401 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), |
| 4402 true, I::kNodeIsPartiallyDependentShift); |
4379 } | 4403 } |
4380 | 4404 |
4381 template <class T> | 4405 template <class T> |
4382 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { | 4406 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { |
4383 V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id); | 4407 V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id); |
4384 } | 4408 } |
4385 | 4409 |
4386 template <class T> | 4410 template <class T> |
4387 uint16_t Persistent<T>::WrapperClassId() const { | 4411 uint16_t Persistent<T>::WrapperClassId() const { |
4388 return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this)); | 4412 return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this)); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4805 | 4829 |
4806 | 4830 |
4807 } // namespace v8 | 4831 } // namespace v8 |
4808 | 4832 |
4809 | 4833 |
4810 #undef V8EXPORT | 4834 #undef V8EXPORT |
4811 #undef TYPE_CHECK | 4835 #undef TYPE_CHECK |
4812 | 4836 |
4813 | 4837 |
4814 #endif // V8_H_ | 4838 #endif // V8_H_ |
OLD | NEW |