Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Side by Side Diff: src/objects-inl.h

Issue 12223071: ES6 symbols: Introduce Symbol class, along with abstract Name class (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 173
174 bool Object::NonFailureIsHeapObject() { 174 bool Object::NonFailureIsHeapObject() {
175 ASSERT(!this->IsFailure()); 175 ASSERT(!this->IsFailure());
176 return (reinterpret_cast<intptr_t>(this) & kSmiTagMask) != 0; 176 return (reinterpret_cast<intptr_t>(this) & kSmiTagMask) != 0;
177 } 177 }
178 178
179 179
180 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) 180 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
181 TYPE_CHECKER(Symbol, SYMBOL_TYPE)
182
183
184 bool Object::IsName() {
185 return Object::IsHeapObject()
186 && HeapObject::cast(this)->map()->instance_type() <= LAST_NAME_TYPE;
187 }
181 188
182 189
183 bool Object::IsString() { 190 bool Object::IsString() {
184 return Object::IsHeapObject() 191 return Object::IsHeapObject()
185 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; 192 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE;
186 } 193 }
187 194
188 195
189 bool Object::IsSpecObject() { 196 bool Object::IsSpecObject() {
190 return Object::IsHeapObject() 197 return Object::IsHeapObject()
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 CAST_ACCESSOR(MapCache) 2411 CAST_ACCESSOR(MapCache)
2405 CAST_ACCESSOR(String) 2412 CAST_ACCESSOR(String)
2406 CAST_ACCESSOR(SeqString) 2413 CAST_ACCESSOR(SeqString)
2407 CAST_ACCESSOR(SeqOneByteString) 2414 CAST_ACCESSOR(SeqOneByteString)
2408 CAST_ACCESSOR(SeqTwoByteString) 2415 CAST_ACCESSOR(SeqTwoByteString)
2409 CAST_ACCESSOR(SlicedString) 2416 CAST_ACCESSOR(SlicedString)
2410 CAST_ACCESSOR(ConsString) 2417 CAST_ACCESSOR(ConsString)
2411 CAST_ACCESSOR(ExternalString) 2418 CAST_ACCESSOR(ExternalString)
2412 CAST_ACCESSOR(ExternalAsciiString) 2419 CAST_ACCESSOR(ExternalAsciiString)
2413 CAST_ACCESSOR(ExternalTwoByteString) 2420 CAST_ACCESSOR(ExternalTwoByteString)
2421 CAST_ACCESSOR(Symbol)
2414 CAST_ACCESSOR(JSReceiver) 2422 CAST_ACCESSOR(JSReceiver)
2415 CAST_ACCESSOR(JSObject) 2423 CAST_ACCESSOR(JSObject)
2416 CAST_ACCESSOR(Smi) 2424 CAST_ACCESSOR(Smi)
2417 CAST_ACCESSOR(HeapObject) 2425 CAST_ACCESSOR(HeapObject)
2418 CAST_ACCESSOR(HeapNumber) 2426 CAST_ACCESSOR(HeapNumber)
2419 CAST_ACCESSOR(Oddball) 2427 CAST_ACCESSOR(Oddball)
2420 CAST_ACCESSOR(JSGlobalPropertyCell) 2428 CAST_ACCESSOR(JSGlobalPropertyCell)
2421 CAST_ACCESSOR(SharedFunctionInfo) 2429 CAST_ACCESSOR(SharedFunctionInfo)
2422 CAST_ACCESSOR(Map) 2430 CAST_ACCESSOR(Map)
2423 CAST_ACCESSOR(JSFunction) 2431 CAST_ACCESSOR(JSFunction)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 return reinterpret_cast<HashTable*>(obj); 2468 return reinterpret_cast<HashTable*>(obj);
2461 } 2469 }
2462 2470
2463 2471
2464 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) 2472 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
2465 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) 2473 SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
2466 2474
2467 SMI_ACCESSORS(String, length, kLengthOffset) 2475 SMI_ACCESSORS(String, length, kLengthOffset)
2468 2476
2469 2477
2470 uint32_t String::hash_field() { 2478 uint32_t Name::hash_field() {
2471 return READ_UINT32_FIELD(this, kHashFieldOffset); 2479 return READ_UINT32_FIELD(this, kHashFieldOffset);
2472 } 2480 }
2473 2481
2474 2482
2475 void String::set_hash_field(uint32_t value) { 2483 void Name::set_hash_field(uint32_t value) {
2476 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); 2484 WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
2477 #if V8_HOST_ARCH_64_BIT 2485 #if V8_HOST_ARCH_64_BIT
2478 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); 2486 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0);
2479 #endif 2487 #endif
2480 } 2488 }
2481 2489
2482 2490
2483 bool String::Equals(String* other) { 2491 bool String::Equals(String* other) {
2484 if (other == this) return true; 2492 if (other == this) return true;
2485 if (StringShape(this).IsInternalized() && 2493 if (StringShape(this).IsInternalized() &&
(...skipping 2738 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 return StringDictionary::cast(properties()); 5232 return StringDictionary::cast(properties());
5225 } 5233 }
5226 5234
5227 5235
5228 SeededNumberDictionary* JSObject::element_dictionary() { 5236 SeededNumberDictionary* JSObject::element_dictionary() {
5229 ASSERT(HasDictionaryElements()); 5237 ASSERT(HasDictionaryElements());
5230 return SeededNumberDictionary::cast(elements()); 5238 return SeededNumberDictionary::cast(elements());
5231 } 5239 }
5232 5240
5233 5241
5234 bool String::IsHashFieldComputed(uint32_t field) { 5242 bool Name::IsHashFieldComputed(uint32_t field) {
5235 return (field & kHashNotComputedMask) == 0; 5243 return (field & kHashNotComputedMask) == 0;
5236 } 5244 }
5237 5245
5238 5246
5239 bool String::HasHashCode() { 5247 bool Name::HasHashCode() {
5240 return IsHashFieldComputed(hash_field()); 5248 return IsHashFieldComputed(hash_field());
5241 } 5249 }
5242 5250
5243 5251
5244 uint32_t String::Hash() { 5252 uint32_t Name::Hash() {
5245 // Fast case: has hash code already been computed? 5253 // Fast case: has hash code already been computed?
5246 uint32_t field = hash_field(); 5254 uint32_t field = hash_field();
5247 if (IsHashFieldComputed(field)) return field >> kHashShift; 5255 if (IsHashFieldComputed(field)) return field >> kHashShift;
5248 // Slow case: compute hash code and set it. 5256 // Slow case: compute hash code and set it. Has to be a string.
5249 return ComputeAndSetHash(); 5257 return String::cast(this)->ComputeAndSetHash();
5250 } 5258 }
5251 5259
5252 5260
5253 StringHasher::StringHasher(int length, uint32_t seed) 5261 StringHasher::StringHasher(int length, uint32_t seed)
5254 : length_(length), 5262 : length_(length),
5255 raw_running_hash_(seed), 5263 raw_running_hash_(seed),
5256 array_index_(0), 5264 array_index_(0),
5257 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), 5265 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize),
5258 is_first_char_(true) { 5266 is_first_char_(true) {
5259 ASSERT(FLAG_randomize_hashes || raw_running_hash_ == 0); 5267 ASSERT(FLAG_randomize_hashes || raw_running_hash_ == 0);
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
5892 #undef WRITE_UINT32_FIELD 5900 #undef WRITE_UINT32_FIELD
5893 #undef READ_SHORT_FIELD 5901 #undef READ_SHORT_FIELD
5894 #undef WRITE_SHORT_FIELD 5902 #undef WRITE_SHORT_FIELD
5895 #undef READ_BYTE_FIELD 5903 #undef READ_BYTE_FIELD
5896 #undef WRITE_BYTE_FIELD 5904 #undef WRITE_BYTE_FIELD
5897 5905
5898 5906
5899 } } // namespace v8::internal 5907 } } // namespace v8::internal
5900 5908
5901 #endif // V8_OBJECTS_INL_H_ 5909 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698