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 5283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5294 static const int kForeignAddressOffset = kApiPointerSize; | 5294 static const int kForeignAddressOffset = kApiPointerSize; |
5295 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 5295 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
5296 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 5296 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
5297 static const int kContextHeaderSize = 2 * kApiPointerSize; | 5297 static const int kContextHeaderSize = 2 * kApiPointerSize; |
5298 static const int kContextEmbedderDataIndex = 65; | 5298 static const int kContextEmbedderDataIndex = 65; |
5299 static const int kFullStringRepresentationMask = 0x07; | 5299 static const int kFullStringRepresentationMask = 0x07; |
5300 static const int kStringEncodingMask = 0x4; | 5300 static const int kStringEncodingMask = 0x4; |
5301 static const int kExternalTwoByteRepresentationTag = 0x02; | 5301 static const int kExternalTwoByteRepresentationTag = 0x02; |
5302 static const int kExternalAsciiRepresentationTag = 0x06; | 5302 static const int kExternalAsciiRepresentationTag = 0x06; |
5303 | 5303 |
| 5304 static const int kIsolateStateOffset = 0; |
5304 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 5305 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; |
5305 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 5306 static const int kIsolateRootsOffset = 3 * kApiPointerSize; |
5306 static const int kUndefinedValueRootIndex = 5; | 5307 static const int kUndefinedValueRootIndex = 5; |
5307 static const int kNullValueRootIndex = 7; | 5308 static const int kNullValueRootIndex = 7; |
5308 static const int kTrueValueRootIndex = 8; | 5309 static const int kTrueValueRootIndex = 8; |
5309 static const int kFalseValueRootIndex = 9; | 5310 static const int kFalseValueRootIndex = 9; |
5310 static const int kEmptyStringRootIndex = 131; | 5311 static const int kEmptyStringRootIndex = 131; |
5311 | 5312 |
5312 static const int kNodeClassIdOffset = 1 * kApiPointerSize; | 5313 static const int kNodeClassIdOffset = 1 * kApiPointerSize; |
5313 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; | 5314 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; |
5314 static const int kNodeStateMask = 0xf; | 5315 static const int kNodeStateMask = 0xf; |
5315 static const int kNodeStateIsWeakValue = 2; | 5316 static const int kNodeStateIsWeakValue = 2; |
5316 static const int kNodeStateIsNearDeathValue = 4; | 5317 static const int kNodeStateIsNearDeathValue = 4; |
5317 static const int kNodeIsIndependentShift = 4; | 5318 static const int kNodeIsIndependentShift = 4; |
5318 static const int kNodeIsPartiallyDependentShift = 5; | 5319 static const int kNodeIsPartiallyDependentShift = 5; |
5319 | 5320 |
5320 static const int kJSObjectType = 0xb0; | 5321 static const int kJSObjectType = 0xb0; |
5321 static const int kFirstNonstringType = 0x80; | 5322 static const int kFirstNonstringType = 0x80; |
5322 static const int kOddballType = 0x83; | 5323 static const int kOddballType = 0x83; |
5323 static const int kForeignType = 0x88; | 5324 static const int kForeignType = 0x88; |
5324 | 5325 |
5325 static const int kUndefinedOddballKind = 5; | 5326 static const int kUndefinedOddballKind = 5; |
5326 static const int kNullOddballKind = 3; | 5327 static const int kNullOddballKind = 3; |
5327 | 5328 |
5328 #ifdef V8_ENABLE_CHECKS | |
5329 static void CheckInitialized(v8::Isolate* isolate); | |
5330 #else | |
5331 static void CheckInitialized(v8::Isolate* isolate) { } | |
5332 #endif | |
5333 | |
5334 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { | 5329 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { |
5335 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 5330 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
5336 kHeapObjectTag); | 5331 kHeapObjectTag); |
5337 } | 5332 } |
5338 | 5333 |
5339 V8_INLINE(static int SmiValue(internal::Object* value)) { | 5334 V8_INLINE(static int SmiValue(internal::Object* value)) { |
5340 return PlatformSmiTagging::SmiToInt(value); | 5335 return PlatformSmiTagging::SmiToInt(value); |
5341 } | 5336 } |
5342 | 5337 |
5343 V8_INLINE(static internal::Object* IntToSmi(int value)) { | 5338 V8_INLINE(static internal::Object* IntToSmi(int value)) { |
(...skipping 13 matching lines...) Expand all Loading... |
5357 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { | 5352 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { |
5358 typedef internal::Object O; | 5353 typedef internal::Object O; |
5359 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | 5354 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); |
5360 } | 5355 } |
5361 | 5356 |
5362 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { | 5357 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { |
5363 int representation = (instance_type & kFullStringRepresentationMask); | 5358 int representation = (instance_type & kFullStringRepresentationMask); |
5364 return representation == kExternalTwoByteRepresentationTag; | 5359 return representation == kExternalTwoByteRepresentationTag; |
5365 } | 5360 } |
5366 | 5361 |
| 5362 V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { |
| 5363 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; |
| 5364 return *reinterpret_cast<int*>(addr) == 1; |
| 5365 } |
| 5366 |
5367 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { | 5367 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { |
5368 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5368 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
5369 return *addr & (1 << shift); | 5369 return *addr & (1 << shift); |
5370 } | 5370 } |
5371 | 5371 |
5372 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, | 5372 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, |
5373 bool value, int shift)) { | 5373 bool value, int shift)) { |
5374 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5374 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
5375 uint8_t mask = 1 << shift; | 5375 uint8_t mask = 1 << shift; |
5376 *addr = (*addr & ~mask) | (value << shift); | 5376 *addr = (*addr & ~mask) | (value << shift); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5932 #ifdef V8_ENABLE_CHECKS | 5932 #ifdef V8_ENABLE_CHECKS |
5933 CheckCast(value); | 5933 CheckCast(value); |
5934 #endif | 5934 #endif |
5935 return static_cast<String*>(value); | 5935 return static_cast<String*>(value); |
5936 } | 5936 } |
5937 | 5937 |
5938 | 5938 |
5939 Local<String> String::Empty(Isolate* isolate) { | 5939 Local<String> String::Empty(Isolate* isolate) { |
5940 typedef internal::Object* S; | 5940 typedef internal::Object* S; |
5941 typedef internal::Internals I; | 5941 typedef internal::Internals I; |
5942 I::CheckInitialized(isolate); | 5942 if (!I::IsInitialized(isolate)) return Empty(); |
5943 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 5943 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); |
5944 return Local<String>(reinterpret_cast<String*>(slot)); | 5944 return Local<String>(reinterpret_cast<String*>(slot)); |
5945 } | 5945 } |
5946 | 5946 |
5947 | 5947 |
5948 Local<String> String::New(const char* data, int length) { | 5948 Local<String> String::New(const char* data, int length) { |
5949 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); | 5949 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); |
5950 } | 5950 } |
5951 | 5951 |
5952 | 5952 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6285 | 6285 |
6286 template<typename T> | 6286 template<typename T> |
6287 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { | 6287 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { |
6288 return ReturnValue<T>(&args_[kReturnValueIndex]); | 6288 return ReturnValue<T>(&args_[kReturnValueIndex]); |
6289 } | 6289 } |
6290 | 6290 |
6291 | 6291 |
6292 Handle<Primitive> Undefined(Isolate* isolate) { | 6292 Handle<Primitive> Undefined(Isolate* isolate) { |
6293 typedef internal::Object* S; | 6293 typedef internal::Object* S; |
6294 typedef internal::Internals I; | 6294 typedef internal::Internals I; |
6295 I::CheckInitialized(isolate); | 6295 if (!I::IsInitialized(isolate)) return Undefined(); |
6296 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); | 6296 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); |
6297 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | 6297 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); |
6298 } | 6298 } |
6299 | 6299 |
6300 | 6300 |
6301 Handle<Primitive> Null(Isolate* isolate) { | 6301 Handle<Primitive> Null(Isolate* isolate) { |
6302 typedef internal::Object* S; | 6302 typedef internal::Object* S; |
6303 typedef internal::Internals I; | 6303 typedef internal::Internals I; |
6304 I::CheckInitialized(isolate); | 6304 if (!I::IsInitialized(isolate)) return Null(); |
6305 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); | 6305 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); |
6306 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | 6306 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); |
6307 } | 6307 } |
6308 | 6308 |
6309 | 6309 |
6310 Handle<Boolean> True(Isolate* isolate) { | 6310 Handle<Boolean> True(Isolate* isolate) { |
6311 typedef internal::Object* S; | 6311 typedef internal::Object* S; |
6312 typedef internal::Internals I; | 6312 typedef internal::Internals I; |
6313 I::CheckInitialized(isolate); | 6313 if (!I::IsInitialized(isolate)) return True(); |
6314 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); | 6314 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); |
6315 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 6315 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
6316 } | 6316 } |
6317 | 6317 |
6318 | 6318 |
6319 Handle<Boolean> False(Isolate* isolate) { | 6319 Handle<Boolean> False(Isolate* isolate) { |
6320 typedef internal::Object* S; | 6320 typedef internal::Object* S; |
6321 typedef internal::Internals I; | 6321 typedef internal::Internals I; |
6322 I::CheckInitialized(isolate); | 6322 if (!I::IsInitialized(isolate)) return False(); |
6323 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | 6323 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); |
6324 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 6324 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
6325 } | 6325 } |
6326 | 6326 |
6327 | 6327 |
6328 void Isolate::SetData(void* data) { | 6328 void Isolate::SetData(void* data) { |
6329 typedef internal::Internals I; | 6329 typedef internal::Internals I; |
6330 I::SetEmbedderData(this, data); | 6330 I::SetEmbedderData(this, data); |
6331 } | 6331 } |
6332 | 6332 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6372 | 6372 |
6373 | 6373 |
6374 } // namespace v8 | 6374 } // namespace v8 |
6375 | 6375 |
6376 | 6376 |
6377 #undef V8EXPORT | 6377 #undef V8EXPORT |
6378 #undef TYPE_CHECK | 6378 #undef TYPE_CHECK |
6379 | 6379 |
6380 | 6380 |
6381 #endif // V8_H_ | 6381 #endif // V8_H_ |
OLD | NEW |