Chromium Code Reviews| 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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1890 | 1890 |
| 1891 // Disallow copying and assigning. | 1891 // Disallow copying and assigning. |
| 1892 Value(const Value&); | 1892 Value(const Value&); |
| 1893 void operator=(const Value&); | 1893 void operator=(const Value&); |
| 1894 }; | 1894 }; |
| 1895 | 1895 |
| 1896 private: | 1896 private: |
| 1897 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, | 1897 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, |
| 1898 Encoding encoding) const; | 1898 Encoding encoding) const; |
| 1899 void VerifyExternalStringResource(ExternalStringResource* val) const; | 1899 void VerifyExternalStringResource(ExternalStringResource* val) const; |
| 1900 static internal::Object* GetRedirectedString(internal::Object* cons); | |
| 1900 static void CheckCast(v8::Value* obj); | 1901 static void CheckCast(v8::Value* obj); |
| 1901 }; | 1902 }; |
| 1902 | 1903 |
| 1903 | 1904 |
| 1904 /** | 1905 /** |
| 1905 * A JavaScript symbol (ECMA-262 edition 6) | 1906 * A JavaScript symbol (ECMA-262 edition 6) |
| 1906 * | 1907 * |
| 1907 * This is an experimental feature. Use at your own risk. | 1908 * This is an experimental feature. Use at your own risk. |
| 1908 */ | 1909 */ |
| 1909 class V8_EXPORT Symbol : public Primitive { | 1910 class V8_EXPORT Symbol : public Primitive { |
| (...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5381 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; | 5382 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; |
| 5382 static const int kStringResourceOffset = 3 * kApiPointerSize; | 5383 static const int kStringResourceOffset = 3 * kApiPointerSize; |
| 5383 | 5384 |
| 5384 static const int kOddballKindOffset = 3 * kApiPointerSize; | 5385 static const int kOddballKindOffset = 3 * kApiPointerSize; |
| 5385 static const int kForeignAddressOffset = kApiPointerSize; | 5386 static const int kForeignAddressOffset = kApiPointerSize; |
| 5386 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 5387 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
| 5387 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 5388 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
| 5388 static const int kContextHeaderSize = 2 * kApiPointerSize; | 5389 static const int kContextHeaderSize = 2 * kApiPointerSize; |
| 5389 static const int kContextEmbedderDataIndex = 65; | 5390 static const int kContextEmbedderDataIndex = 65; |
| 5390 static const int kFullStringRepresentationMask = 0x07; | 5391 static const int kFullStringRepresentationMask = 0x07; |
| 5392 static const int kStringRepresentationMask = 0x03; | |
| 5391 static const int kStringEncodingMask = 0x4; | 5393 static const int kStringEncodingMask = 0x4; |
| 5394 static const int kConsTwoByteRepresentationTag = 0x01; | |
| 5392 static const int kExternalTwoByteRepresentationTag = 0x02; | 5395 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 5393 static const int kExternalAsciiRepresentationTag = 0x06; | 5396 static const int kConsRepresentationTag = 0x01; |
| 5397 static const int kExternalRepresentationTag = 0x02; | |
| 5394 | 5398 |
| 5395 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; | 5399 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; |
| 5396 static const int kIsolateRootsOffset = 5 * kApiPointerSize; | 5400 static const int kIsolateRootsOffset = 5 * kApiPointerSize; |
| 5397 static const int kUndefinedValueRootIndex = 5; | 5401 static const int kUndefinedValueRootIndex = 5; |
| 5398 static const int kNullValueRootIndex = 7; | 5402 static const int kNullValueRootIndex = 7; |
| 5399 static const int kTrueValueRootIndex = 8; | 5403 static const int kTrueValueRootIndex = 8; |
| 5400 static const int kFalseValueRootIndex = 9; | 5404 static const int kFalseValueRootIndex = 9; |
| 5401 static const int kEmptyStringRootIndex = 146; | 5405 static const int kEmptyStringRootIndex = 146; |
| 5402 | 5406 |
| 5403 static const int kNodeClassIdOffset = 1 * kApiPointerSize; | 5407 static const int kNodeClassIdOffset = 1 * kApiPointerSize; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5447 typedef internal::Object O; | 5451 typedef internal::Object O; |
| 5448 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | 5452 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); |
| 5449 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | 5453 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); |
| 5450 } | 5454 } |
| 5451 | 5455 |
| 5452 V8_INLINE static int GetOddballKind(internal::Object* obj) { | 5456 V8_INLINE static int GetOddballKind(internal::Object* obj) { |
| 5453 typedef internal::Object O; | 5457 typedef internal::Object O; |
| 5454 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | 5458 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); |
| 5455 } | 5459 } |
| 5456 | 5460 |
| 5457 V8_INLINE static bool IsExternalTwoByteString(int instance_type) { | |
| 5458 int representation = (instance_type & kFullStringRepresentationMask); | |
| 5459 return representation == kExternalTwoByteRepresentationTag; | |
| 5460 } | |
| 5461 | |
| 5462 V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) { | 5461 V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) { |
| 5463 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5462 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5464 return *addr & static_cast<uint8_t>(1U << shift); | 5463 return *addr & static_cast<uint8_t>(1U << shift); |
| 5465 } | 5464 } |
| 5466 | 5465 |
| 5467 V8_INLINE static void UpdateNodeFlag(internal::Object** obj, | 5466 V8_INLINE static void UpdateNodeFlag(internal::Object** obj, |
| 5468 bool value, int shift) { | 5467 bool value, int shift) { |
| 5469 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5468 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5470 uint8_t mask = static_cast<uint8_t>(1 << shift); | 5469 uint8_t mask = static_cast<uint8_t>(1 << shift); |
| 5471 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); | 5470 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5984 I::CheckInitialized(isolate); | 5983 I::CheckInitialized(isolate); |
| 5985 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 5984 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); |
| 5986 return Local<String>(reinterpret_cast<String*>(slot)); | 5985 return Local<String>(reinterpret_cast<String*>(slot)); |
| 5987 } | 5986 } |
| 5988 | 5987 |
| 5989 | 5988 |
| 5990 String::ExternalStringResource* String::GetExternalStringResource() const { | 5989 String::ExternalStringResource* String::GetExternalStringResource() const { |
| 5991 typedef internal::Object O; | 5990 typedef internal::Object O; |
| 5992 typedef internal::Internals I; | 5991 typedef internal::Internals I; |
| 5993 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 5992 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); |
| 5994 String::ExternalStringResource* result; | 5993 String::ExternalStringResource* result = NULL; |
| 5995 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | 5994 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; |
| 5995 // Resolve redirected string via cons string. | |
| 5996 if (type == I::kConsTwoByteRepresentationTag) { | |
| 5997 obj = GetRedirectedString(obj); | |
| 5998 type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; | |
| 5999 } | |
| 6000 if (type == I::kExternalTwoByteRepresentationTag) { | |
| 5996 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 6001 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
| 5997 result = reinterpret_cast<String::ExternalStringResource*>(value); | 6002 result = reinterpret_cast<String::ExternalStringResource*>(value); |
| 5998 } else { | |
| 5999 result = NULL; | |
| 6000 } | 6003 } |
| 6001 #ifdef V8_ENABLE_CHECKS | 6004 #ifdef V8_ENABLE_CHECKS |
| 6002 VerifyExternalStringResource(result); | 6005 VerifyExternalStringResource(result); |
| 6003 #endif | 6006 #endif |
| 6004 return result; | 6007 return result; |
| 6005 } | 6008 } |
| 6006 | 6009 |
| 6007 | 6010 |
| 6008 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( | 6011 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( |
|
dcarney
2014/02/04 15:10:05
this function is ridiculously hot in some dromaeo
| |
| 6009 String::Encoding* encoding_out) const { | 6012 String::Encoding* encoding_out) const { |
| 6010 typedef internal::Object O; | 6013 typedef internal::Object O; |
| 6011 typedef internal::Internals I; | 6014 typedef internal::Internals I; |
| 6012 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 6015 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); |
| 6013 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; | 6016 int instance_type = I::GetInstanceType(obj); |
| 6014 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); | 6017 int string_type = instance_type & I::kStringRepresentationMask; |
| 6018 *encoding_out = static_cast<Encoding>(instance_type & I::kStringEncodingMask); | |
| 6015 ExternalStringResourceBase* resource = NULL; | 6019 ExternalStringResourceBase* resource = NULL; |
| 6016 if (type == I::kExternalAsciiRepresentationTag || | 6020 // Resolve redirected string via cons string. |
| 6017 type == I::kExternalTwoByteRepresentationTag) { | 6021 if (string_type == I::kConsRepresentationTag) { |
| 6022 obj = GetRedirectedString(obj); | |
| 6023 string_type = I::GetInstanceType(obj) & I::kStringRepresentationMask; | |
| 6024 } | |
| 6025 if (string_type == I::kExternalRepresentationTag) { | |
| 6018 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 6026 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
| 6019 resource = static_cast<ExternalStringResourceBase*>(value); | 6027 resource = static_cast<ExternalStringResourceBase*>(value); |
| 6020 } | 6028 } |
| 6021 #ifdef V8_ENABLE_CHECKS | 6029 #ifdef V8_ENABLE_CHECKS |
| 6022 VerifyExternalStringResourceBase(resource, *encoding_out); | 6030 VerifyExternalStringResourceBase(resource, *encoding_out); |
| 6023 #endif | 6031 #endif |
| 6024 return resource; | 6032 return resource; |
| 6025 } | 6033 } |
| 6026 | 6034 |
| 6027 | 6035 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6439 */ | 6447 */ |
| 6440 | 6448 |
| 6441 | 6449 |
| 6442 } // namespace v8 | 6450 } // namespace v8 |
| 6443 | 6451 |
| 6444 | 6452 |
| 6445 #undef TYPE_CHECK | 6453 #undef TYPE_CHECK |
| 6446 | 6454 |
| 6447 | 6455 |
| 6448 #endif // V8_H_ | 6456 #endif // V8_H_ |
| OLD | NEW |