| 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 5329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5340 static const int kForeignAddressOffset = kApiPointerSize; | 5340 static const int kForeignAddressOffset = kApiPointerSize; |
| 5341 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 5341 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
| 5342 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 5342 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
| 5343 static const int kContextHeaderSize = 2 * kApiPointerSize; | 5343 static const int kContextHeaderSize = 2 * kApiPointerSize; |
| 5344 static const int kContextEmbedderDataIndex = 65; | 5344 static const int kContextEmbedderDataIndex = 65; |
| 5345 static const int kFullStringRepresentationMask = 0x07; | 5345 static const int kFullStringRepresentationMask = 0x07; |
| 5346 static const int kStringEncodingMask = 0x4; | 5346 static const int kStringEncodingMask = 0x4; |
| 5347 static const int kExternalTwoByteRepresentationTag = 0x02; | 5347 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 5348 static const int kExternalAsciiRepresentationTag = 0x06; | 5348 static const int kExternalAsciiRepresentationTag = 0x06; |
| 5349 | 5349 |
| 5350 static const int kIsolateStateOffset = 0; | |
| 5351 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 5350 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; |
| 5352 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 5351 static const int kIsolateRootsOffset = 3 * kApiPointerSize; |
| 5353 static const int kUndefinedValueRootIndex = 5; | 5352 static const int kUndefinedValueRootIndex = 5; |
| 5354 static const int kNullValueRootIndex = 7; | 5353 static const int kNullValueRootIndex = 7; |
| 5355 static const int kTrueValueRootIndex = 8; | 5354 static const int kTrueValueRootIndex = 8; |
| 5356 static const int kFalseValueRootIndex = 9; | 5355 static const int kFalseValueRootIndex = 9; |
| 5357 static const int kEmptyStringRootIndex = 131; | 5356 static const int kEmptyStringRootIndex = 131; |
| 5358 | 5357 |
| 5359 static const int kNodeClassIdOffset = 1 * kApiPointerSize; | 5358 static const int kNodeClassIdOffset = 1 * kApiPointerSize; |
| 5360 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; | 5359 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; |
| 5361 static const int kNodeStateMask = 0xf; | 5360 static const int kNodeStateMask = 0xf; |
| 5362 static const int kNodeStateIsWeakValue = 2; | 5361 static const int kNodeStateIsWeakValue = 2; |
| 5363 static const int kNodeStateIsNearDeathValue = 4; | 5362 static const int kNodeStateIsNearDeathValue = 4; |
| 5364 static const int kNodeIsIndependentShift = 4; | 5363 static const int kNodeIsIndependentShift = 4; |
| 5365 static const int kNodeIsPartiallyDependentShift = 5; | 5364 static const int kNodeIsPartiallyDependentShift = 5; |
| 5366 | 5365 |
| 5367 static const int kJSObjectType = 0xb0; | 5366 static const int kJSObjectType = 0xb0; |
| 5368 static const int kFirstNonstringType = 0x80; | 5367 static const int kFirstNonstringType = 0x80; |
| 5369 static const int kOddballType = 0x83; | 5368 static const int kOddballType = 0x83; |
| 5370 static const int kForeignType = 0x88; | 5369 static const int kForeignType = 0x88; |
| 5371 | 5370 |
| 5372 static const int kUndefinedOddballKind = 5; | 5371 static const int kUndefinedOddballKind = 5; |
| 5373 static const int kNullOddballKind = 3; | 5372 static const int kNullOddballKind = 3; |
| 5374 | 5373 |
| 5374 #ifdef V8_ENABLE_CHECKS |
| 5375 static void CheckInitialized(v8::Isolate* isolate); |
| 5376 #else |
| 5377 static void CheckInitialized(v8::Isolate* isolate) { } |
| 5378 #endif |
| 5379 |
| 5375 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { | 5380 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { |
| 5376 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 5381 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
| 5377 kHeapObjectTag); | 5382 kHeapObjectTag); |
| 5378 } | 5383 } |
| 5379 | 5384 |
| 5380 V8_INLINE(static int SmiValue(internal::Object* value)) { | 5385 V8_INLINE(static int SmiValue(internal::Object* value)) { |
| 5381 return PlatformSmiTagging::SmiToInt(value); | 5386 return PlatformSmiTagging::SmiToInt(value); |
| 5382 } | 5387 } |
| 5383 | 5388 |
| 5384 V8_INLINE(static internal::Object* IntToSmi(int value)) { | 5389 V8_INLINE(static internal::Object* IntToSmi(int value)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5398 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { | 5403 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { |
| 5399 typedef internal::Object O; | 5404 typedef internal::Object O; |
| 5400 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | 5405 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); |
| 5401 } | 5406 } |
| 5402 | 5407 |
| 5403 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { | 5408 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { |
| 5404 int representation = (instance_type & kFullStringRepresentationMask); | 5409 int representation = (instance_type & kFullStringRepresentationMask); |
| 5405 return representation == kExternalTwoByteRepresentationTag; | 5410 return representation == kExternalTwoByteRepresentationTag; |
| 5406 } | 5411 } |
| 5407 | 5412 |
| 5408 V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { | |
| 5409 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; | |
| 5410 return *reinterpret_cast<int*>(addr) == 1; | |
| 5411 } | |
| 5412 | |
| 5413 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { | 5413 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { |
| 5414 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5414 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5415 return *addr & (1 << shift); | 5415 return *addr & (1 << shift); |
| 5416 } | 5416 } |
| 5417 | 5417 |
| 5418 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, | 5418 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, |
| 5419 bool value, int shift)) { | 5419 bool value, int shift)) { |
| 5420 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5420 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5421 uint8_t mask = 1 << shift; | 5421 uint8_t mask = 1 << shift; |
| 5422 *addr = (*addr & ~mask) | (value << shift); | 5422 *addr = (*addr & ~mask) | (value << shift); |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5978 #ifdef V8_ENABLE_CHECKS | 5978 #ifdef V8_ENABLE_CHECKS |
| 5979 CheckCast(value); | 5979 CheckCast(value); |
| 5980 #endif | 5980 #endif |
| 5981 return static_cast<String*>(value); | 5981 return static_cast<String*>(value); |
| 5982 } | 5982 } |
| 5983 | 5983 |
| 5984 | 5984 |
| 5985 Local<String> String::Empty(Isolate* isolate) { | 5985 Local<String> String::Empty(Isolate* isolate) { |
| 5986 typedef internal::Object* S; | 5986 typedef internal::Object* S; |
| 5987 typedef internal::Internals I; | 5987 typedef internal::Internals I; |
| 5988 if (!I::IsInitialized(isolate)) return Empty(); | 5988 I::CheckInitialized(isolate); |
| 5989 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 5989 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); |
| 5990 return Local<String>(reinterpret_cast<String*>(slot)); | 5990 return Local<String>(reinterpret_cast<String*>(slot)); |
| 5991 } | 5991 } |
| 5992 | 5992 |
| 5993 | 5993 |
| 5994 Local<String> String::New(const char* data, int length) { | 5994 Local<String> String::New(const char* data, int length) { |
| 5995 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); | 5995 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); |
| 5996 } | 5996 } |
| 5997 | 5997 |
| 5998 | 5998 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6347 | 6347 |
| 6348 template<typename T> | 6348 template<typename T> |
| 6349 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { | 6349 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { |
| 6350 return ReturnValue<T>(&args_[kReturnValueIndex]); | 6350 return ReturnValue<T>(&args_[kReturnValueIndex]); |
| 6351 } | 6351 } |
| 6352 | 6352 |
| 6353 | 6353 |
| 6354 Handle<Primitive> Undefined(Isolate* isolate) { | 6354 Handle<Primitive> Undefined(Isolate* isolate) { |
| 6355 typedef internal::Object* S; | 6355 typedef internal::Object* S; |
| 6356 typedef internal::Internals I; | 6356 typedef internal::Internals I; |
| 6357 if (!I::IsInitialized(isolate)) return Undefined(); | 6357 I::CheckInitialized(isolate); |
| 6358 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); | 6358 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); |
| 6359 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | 6359 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); |
| 6360 } | 6360 } |
| 6361 | 6361 |
| 6362 | 6362 |
| 6363 Handle<Primitive> Null(Isolate* isolate) { | 6363 Handle<Primitive> Null(Isolate* isolate) { |
| 6364 typedef internal::Object* S; | 6364 typedef internal::Object* S; |
| 6365 typedef internal::Internals I; | 6365 typedef internal::Internals I; |
| 6366 if (!I::IsInitialized(isolate)) return Null(); | 6366 I::CheckInitialized(isolate); |
| 6367 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); | 6367 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); |
| 6368 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | 6368 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); |
| 6369 } | 6369 } |
| 6370 | 6370 |
| 6371 | 6371 |
| 6372 Handle<Boolean> True(Isolate* isolate) { | 6372 Handle<Boolean> True(Isolate* isolate) { |
| 6373 typedef internal::Object* S; | 6373 typedef internal::Object* S; |
| 6374 typedef internal::Internals I; | 6374 typedef internal::Internals I; |
| 6375 if (!I::IsInitialized(isolate)) return True(); | 6375 I::CheckInitialized(isolate); |
| 6376 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); | 6376 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); |
| 6377 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 6377 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
| 6378 } | 6378 } |
| 6379 | 6379 |
| 6380 | 6380 |
| 6381 Handle<Boolean> False(Isolate* isolate) { | 6381 Handle<Boolean> False(Isolate* isolate) { |
| 6382 typedef internal::Object* S; | 6382 typedef internal::Object* S; |
| 6383 typedef internal::Internals I; | 6383 typedef internal::Internals I; |
| 6384 if (!I::IsInitialized(isolate)) return False(); | 6384 I::CheckInitialized(isolate); |
| 6385 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | 6385 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); |
| 6386 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 6386 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
| 6387 } | 6387 } |
| 6388 | 6388 |
| 6389 | 6389 |
| 6390 void Isolate::SetData(void* data) { | 6390 void Isolate::SetData(void* data) { |
| 6391 typedef internal::Internals I; | 6391 typedef internal::Internals I; |
| 6392 I::SetEmbedderData(this, data); | 6392 I::SetEmbedderData(this, data); |
| 6393 } | 6393 } |
| 6394 | 6394 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6434 | 6434 |
| 6435 | 6435 |
| 6436 } // namespace v8 | 6436 } // namespace v8 |
| 6437 | 6437 |
| 6438 | 6438 |
| 6439 #undef V8EXPORT | 6439 #undef V8EXPORT |
| 6440 #undef TYPE_CHECK | 6440 #undef TYPE_CHECK |
| 6441 | 6441 |
| 6442 | 6442 |
| 6443 #endif // V8_H_ | 6443 #endif // V8_H_ |
| OLD | NEW |