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

Unified Diff: src/objects.cc

Issue 11416353: Object.observe support for Function 'prototype' property (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: More comments Created 8 years 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/accessors.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 47c93c4e616c861afa777112686313f509cd7fed..f2a1318ba6d0a7fba85b19f59e61ce95677dfeb9 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -27,6 +27,7 @@
#include "v8.h"
+#include "accessors.h"
#include "api.h"
#include "arguments.h"
#include "bootstrapper.h"
@@ -3107,8 +3108,17 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate);
PropertyAttributes old_attributes = ABSENT;
- if (FLAG_harmony_observation && map()->is_observed()) {
- old_value = handle(lookup.GetLazyValue(), isolate);
+ bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
+ if (is_observed) {
+ // Function prototypes are stored specially
+ if (self->IsJSFunction() &&
+ JSFunction::cast(*self)->should_have_prototype() &&
+ name->Equals(isolate->heap()->prototype_symbol())) {
+ MaybeObject* maybe = Accessors::FunctionGetPrototype(*self, NULL);
+ if (!maybe->ToHandle(&old_value, isolate)) return maybe;
+ } else {
+ old_value = handle(lookup.GetLazyValue(), isolate);
+ }
old_attributes = lookup.GetAttributes();
}
@@ -3172,7 +3182,7 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
Handle<Object> hresult;
if (!result->ToHandle(&hresult, isolate)) return result;
- if (FLAG_harmony_observation && map()->is_observed()) {
+ if (is_observed) {
if (lookup.IsTransition()) {
EnqueueChangeRecord(self, "new", name, old_value);
} else {
« no previous file with comments | « src/accessors.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698