Add Object::IsDirty function in the API.

Review URL: http://codereview.chromium.org/209013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2911 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a0462f3a
...@@ -1238,6 +1238,15 @@ class V8EXPORT Object : public Value { ...@@ -1238,6 +1238,15 @@ class V8EXPORT Object : public Value {
bool SetHiddenValue(Handle<String> key, Handle<Value> value); bool SetHiddenValue(Handle<String> key, Handle<Value> value);
Local<Value> GetHiddenValue(Handle<String> key); Local<Value> GetHiddenValue(Handle<String> key);
bool DeleteHiddenValue(Handle<String> key); bool DeleteHiddenValue(Handle<String> key);
/**
* Returns true if this is an instance of an api function (one
* created from a function created from a function template) and has
* been modified since it was created. Note that this method is
* conservative and may return true for objects that haven't actually
* been modified.
*/
bool IsDirty();
/** /**
* Clone this object with a fast but shallow copy. Values will point * Clone this object with a fast but shallow copy. Values will point
......
...@@ -2156,6 +2156,11 @@ void v8::Object::TurnOnAccessCheck() { ...@@ -2156,6 +2156,11 @@ void v8::Object::TurnOnAccessCheck() {
} }
bool v8::Object::IsDirty() {
return Utils::OpenHandle(this)->IsDirty();
}
Local<v8::Object> v8::Object::Clone() { Local<v8::Object> v8::Object::Clone() {
ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); ON_BAILOUT("v8::Object::Clone()", return Local<Object>());
ENTER_V8; ENTER_V8;
......
...@@ -476,6 +476,21 @@ Object* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) { ...@@ -476,6 +476,21 @@ Object* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) {
} }
bool JSObject::IsDirty() {
Object* cons_obj = map()->constructor();
if (!cons_obj->IsJSFunction())
return true;
JSFunction* fun = JSFunction::cast(cons_obj);
if (!fun->shared()->function_data()->IsFunctionTemplateInfo())
return true;
// If the object is fully fast case and has the same map it was
// created with then no changes can have been made to it.
return map() != fun->initial_map()
|| !HasFastElements()
|| !HasFastProperties();
}
Object* Object::GetProperty(Object* receiver, Object* Object::GetProperty(Object* receiver,
LookupResult* result, LookupResult* result,
String* name, String* name,
......
...@@ -1427,6 +1427,10 @@ class JSObject: public HeapObject { ...@@ -1427,6 +1427,10 @@ class JSObject: public HeapObject {
// Tells whether this object needs to be loaded. // Tells whether this object needs to be loaded.
inline bool IsLoaded(); inline bool IsLoaded();
// Returns true if this is an instance of an api function and has
// been modified since it was created. May give false positives.
bool IsDirty();
bool HasProperty(String* name) { bool HasProperty(String* name) {
return GetPropertyAttribute(name) != ABSENT; return GetPropertyAttribute(name) != ABSENT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment