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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/accessors.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "accessors.h"
30 #include "api.h" 31 #include "api.h"
31 #include "arguments.h" 32 #include "arguments.h"
32 #include "bootstrapper.h" 33 #include "bootstrapper.h"
33 #include "codegen.h" 34 #include "codegen.h"
34 #include "debug.h" 35 #include "debug.h"
35 #include "deoptimizer.h" 36 #include "deoptimizer.h"
36 #include "date.h" 37 #include "date.h"
37 #include "elements.h" 38 #include "elements.h"
38 #include "execution.h" 39 #include "execution.h"
39 #include "full-codegen.h" 40 #include "full-codegen.h"
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 } 3101 }
3101 3102
3102 // From this point on everything needs to be handlified. 3103 // From this point on everything needs to be handlified.
3103 HandleScope scope(isolate); 3104 HandleScope scope(isolate);
3104 Handle<JSObject> self(this); 3105 Handle<JSObject> self(this);
3105 Handle<String> name(name_raw); 3106 Handle<String> name(name_raw);
3106 Handle<Object> value(value_raw, isolate); 3107 Handle<Object> value(value_raw, isolate);
3107 3108
3108 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate); 3109 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate);
3109 PropertyAttributes old_attributes = ABSENT; 3110 PropertyAttributes old_attributes = ABSENT;
3110 if (FLAG_harmony_observation && map()->is_observed()) { 3111 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
3111 old_value = handle(lookup.GetLazyValue(), isolate); 3112 if (is_observed) {
3113 // Function prototypes are stored specially
3114 if (self->IsJSFunction() &&
3115 JSFunction::cast(*self)->should_have_prototype() &&
3116 name->Equals(isolate->heap()->prototype_symbol())) {
3117 MaybeObject* maybe = Accessors::FunctionGetPrototype(*self, NULL);
3118 if (!maybe->ToHandle(&old_value, isolate)) return maybe;
3119 } else {
3120 old_value = handle(lookup.GetLazyValue(), isolate);
3121 }
3112 old_attributes = lookup.GetAttributes(); 3122 old_attributes = lookup.GetAttributes();
3113 } 3123 }
3114 3124
3115 // Check of IsReadOnly removed from here in clone. 3125 // Check of IsReadOnly removed from here in clone.
3116 MaybeObject* result = *value; 3126 MaybeObject* result = *value;
3117 switch (lookup.type()) { 3127 switch (lookup.type()) {
3118 case NORMAL: { 3128 case NORMAL: {
3119 PropertyDetails details = PropertyDetails(attributes, NORMAL); 3129 PropertyDetails details = PropertyDetails(attributes, NORMAL);
3120 result = self->SetNormalizedProperty(*name, *value, details); 3130 result = self->SetNormalizedProperty(*name, *value, details);
3121 break; 3131 break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 break; 3175 break;
3166 } 3176 }
3167 case HANDLER: 3177 case HANDLER:
3168 case NONEXISTENT: 3178 case NONEXISTENT:
3169 UNREACHABLE(); 3179 UNREACHABLE();
3170 } 3180 }
3171 3181
3172 Handle<Object> hresult; 3182 Handle<Object> hresult;
3173 if (!result->ToHandle(&hresult, isolate)) return result; 3183 if (!result->ToHandle(&hresult, isolate)) return result;
3174 3184
3175 if (FLAG_harmony_observation && map()->is_observed()) { 3185 if (is_observed) {
3176 if (lookup.IsTransition()) { 3186 if (lookup.IsTransition()) {
3177 EnqueueChangeRecord(self, "new", name, old_value); 3187 EnqueueChangeRecord(self, "new", name, old_value);
3178 } else { 3188 } else {
3179 LookupResult new_lookup(isolate); 3189 LookupResult new_lookup(isolate);
3180 self->LocalLookup(*name, &new_lookup, true); 3190 self->LocalLookup(*name, &new_lookup, true);
3181 ASSERT(!new_lookup.GetLazyValue()->IsTheHole()); 3191 ASSERT(!new_lookup.GetLazyValue()->IsTheHole());
3182 if (old_value->IsTheHole() || 3192 if (old_value->IsTheHole() ||
3183 new_lookup.GetAttributes() != old_attributes) { 3193 new_lookup.GetAttributes() != old_attributes) {
3184 EnqueueChangeRecord(self, "reconfigured", name, old_value); 3194 EnqueueChangeRecord(self, "reconfigured", name, old_value);
3185 } else if (!new_lookup.GetLazyValue()->SameValue(*old_value)) { 3195 } else if (!new_lookup.GetLazyValue()->SameValue(*old_value)) {
(...skipping 10845 matching lines...) Expand 10 before | Expand all | Expand 10 after
14031 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 14041 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
14032 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 14042 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
14033 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 14043 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
14034 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 14044 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
14035 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 14045 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
14036 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 14046 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
14037 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 14047 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
14038 } 14048 }
14039 14049
14040 } } // namespace v8::internal 14050 } } // namespace v8::internal
OLDNEW
« 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