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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index c9e8d69c6476b3a9054505032497ca1ca15f69b6..590023ec8a775dd2a47dfc3f0d5a98b5f2b3e507 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -178,6 +178,13 @@ bool Object::NonFailureIsHeapObject() {
TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
+TYPE_CHECKER(Symbol, SYMBOL_TYPE)
+
+
+bool Object::IsName() {
+ return Object::IsHeapObject()
+ && HeapObject::cast(this)->map()->instance_type() <= LAST_NAME_TYPE;
+}
bool Object::IsString() {
@@ -2411,6 +2418,7 @@ CAST_ACCESSOR(ConsString)
CAST_ACCESSOR(ExternalString)
CAST_ACCESSOR(ExternalAsciiString)
CAST_ACCESSOR(ExternalTwoByteString)
+CAST_ACCESSOR(Symbol)
CAST_ACCESSOR(JSReceiver)
CAST_ACCESSOR(JSObject)
CAST_ACCESSOR(Smi)
@@ -2467,12 +2475,12 @@ SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
SMI_ACCESSORS(String, length, kLengthOffset)
-uint32_t String::hash_field() {
+uint32_t Name::hash_field() {
return READ_UINT32_FIELD(this, kHashFieldOffset);
}
-void String::set_hash_field(uint32_t value) {
+void Name::set_hash_field(uint32_t value) {
WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
#if V8_HOST_ARCH_64_BIT
WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0);
@@ -5231,22 +5239,22 @@ SeededNumberDictionary* JSObject::element_dictionary() {
}
-bool String::IsHashFieldComputed(uint32_t field) {
+bool Name::IsHashFieldComputed(uint32_t field) {
return (field & kHashNotComputedMask) == 0;
}
-bool String::HasHashCode() {
+bool Name::HasHashCode() {
return IsHashFieldComputed(hash_field());
}
-uint32_t String::Hash() {
+uint32_t Name::Hash() {
// Fast case: has hash code already been computed?
uint32_t field = hash_field();
if (IsHashFieldComputed(field)) return field >> kHashShift;
- // Slow case: compute hash code and set it.
- return ComputeAndSetHash();
+ // Slow case: compute hash code and set it. Has to be a string.
+ return String::cast(this)->ComputeAndSetHash();
}
« 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