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

Unified Diff: src/objects-inl.h

Issue 48923002: Provide private symbols through internal APIs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make privates a non-value; comments Created 7 years, 2 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
« src/objects.h ('K') | « src/objects-debug.cc ('k') | src/parser.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 d9d36e0f4be1147ad8d5e3eee2c9625f6b024c1e..e8723a593a010344919603d5777af6bab9c079cf 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -189,6 +189,11 @@ TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
TYPE_CHECKER(Symbol, SYMBOL_TYPE)
+bool Object::IsPrivate() {
+ return IsSymbol() && Symbol::cast(this)->name()->IsBox();
+}
+
+
bool Object::IsString() {
return Object::IsHeapObject()
&& HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE;
@@ -2602,6 +2607,7 @@ CAST_ACCESSOR(ExternalString)
CAST_ACCESSOR(ExternalAsciiString)
CAST_ACCESSOR(ExternalTwoByteString)
CAST_ACCESSOR(Symbol)
+CAST_ACCESSOR(Private)
CAST_ACCESSOR(Name)
CAST_ACCESSOR(JSReceiver)
CAST_ACCESSOR(JSObject)
@@ -2692,6 +2698,18 @@ bool Name::Equals(Name* other) {
ACCESSORS(Symbol, name, Object, kNameOffset)
+Object* Private::name() {
+ ASSERT(IsPrivate());
+ return Box::cast(Symbol::name())->value();
Yang 2013/10/29 12:47:26 could we assert in those accessors that the value
rossberg 2013/10/29 15:08:19 Yeah, that is nasty. I decided to remove the whole
+}
+
+
+void Private::set_name(Object* value, WriteBarrierMode mode) {
+ ASSERT(IsPrivate());
+ return Box::cast(Symbol::name())->set_value(value, mode);
+}
+
+
bool String::Equals(String* other) {
if (other == this) return true;
if (this->IsInternalizedString() && other->IsInternalizedString()) {
« src/objects.h ('K') | « src/objects-debug.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698