Revision: 15329
Author: [email protected]
Date: Wed Jun 26 01:00:05 2013
Log: Allow users of the V8 API to distinguish between unset and
undefined HiddenValues
BUG=v8:2746
[email protected]
Review URL: https://codereview.chromium.org/17781002
Patch from Adam Klein <[email protected]>.
http://code.google.com/p/v8/source/detail?r=15329
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/src/api.cc Tue Jun 25 07:57:47 2013
+++ /branches/bleeding_edge/src/api.cc Wed Jun 26 01:00:05 2013
@@ -3935,7 +3935,7 @@
i::Handle<i::String> key_string =
isolate->factory()->InternalizeString(key_obj);
i::Handle<i::Object> result(self->GetHiddenProperty(*key_string),
isolate);
- if (result->IsUndefined()) return v8::Local<v8::Value>();
+ if (result->IsTheHole()) return v8::Local<v8::Value>();
return Utils::ToLocal(result);
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Tue Jun 25 02:34:22 2013
+++ /branches/bleeding_edge/src/objects.cc Wed Jun 26 01:00:05 2013
@@ -4734,7 +4734,7 @@
// For a proxy, use the prototype as target object.
Object* proxy_parent = GetPrototype();
// If the proxy is detached, return undefined.
- if (proxy_parent->IsNull()) return GetHeap()->undefined_value();
+ if (proxy_parent->IsNull()) return GetHeap()->the_hole_value();
ASSERT(proxy_parent->IsJSGlobalObject());
return JSObject::cast(proxy_parent)->GetHiddenProperty(key);
}
@@ -4748,15 +4748,14 @@
if (key == GetHeap()->identity_hash_string()) {
return inline_value;
} else {
- return GetHeap()->undefined_value();
+ return GetHeap()->the_hole_value();
}
}
- if (inline_value->IsUndefined()) return GetHeap()->undefined_value();
+ if (inline_value->IsUndefined()) return GetHeap()->the_hole_value();
ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value);
Object* entry = hashtable->Lookup(key);
- if (entry->IsTheHole()) return GetHeap()->undefined_value();
return entry;
}
=======================================
--- /branches/bleeding_edge/src/objects.h Tue Jun 25 07:57:47 2013
+++ /branches/bleeding_edge/src/objects.h Wed Jun 26 01:00:05 2013
@@ -1996,7 +1996,7 @@
Handle<Object> value);
// Returns a failure if a GC is required.
MUST_USE_RESULT MaybeObject* SetHiddenProperty(Name* key, Object* value);
- // Gets the value of a hidden property with the given key. Returns
undefined
+ // Gets the value of a hidden property with the given key. Returns the
hole
// if the property doesn't exist (or if called on a detached proxy),
// otherwise returns the value set for the key.
Object* GetHiddenProperty(Name* key);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Jun 25 06:48:43 2013
+++ /branches/bleeding_edge/src/runtime.cc Wed Jun 26 01:00:05 2013
@@ -13380,6 +13380,7 @@
CONVERT_ARG_CHECKED(JSObject, error_object, 0);
String* key = isolate->heap()->hidden_stack_trace_string();
Object* result = error_object->GetHiddenProperty(key);
+ if (result->IsTheHole()) result = isolate->heap()->undefined_value();
RUNTIME_ASSERT(result->IsJSArray() ||
result->IsString() ||
result->IsUndefined());
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Tue Jun 25 01:11:50 2013
+++ /branches/bleeding_edge/test/cctest/test-api.cc Wed Jun 26 01:00:05 2013
@@ -19278,6 +19278,18 @@
Local<Object> map_object(Local<Object>::Cast(map_value));
CHECK_EQ(0, map_object->InternalFieldCount());
}
+
+
+THREADED_TEST(Regress2746) {
+ LocalContext context;
+ v8::HandleScope scope(context->GetIsolate());
+ Local<Object> obj = Object::New();
+ Local<String> key = String::New("key");
+ obj->SetHiddenValue(key, v8::Undefined());
+ Local<Value> value = obj->GetHiddenValue(key);
+ CHECK(!value.IsEmpty());
+ CHECK(value->IsUndefined());
+}
#ifndef WIN32
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.