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

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: 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
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 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 } 3098 }
3098 3099
3099 // From this point on everything needs to be handlified. 3100 // From this point on everything needs to be handlified.
3100 HandleScope scope(isolate); 3101 HandleScope scope(isolate);
3101 Handle<JSObject> self(this); 3102 Handle<JSObject> self(this);
3102 Handle<String> name(name_raw); 3103 Handle<String> name(name_raw);
3103 Handle<Object> value(value_raw, isolate); 3104 Handle<Object> value(value_raw, isolate);
3104 3105
3105 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate); 3106 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate);
3106 PropertyAttributes old_attributes = ABSENT; 3107 PropertyAttributes old_attributes = ABSENT;
3107 if (FLAG_harmony_observation && map()->is_observed()) { 3108 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
3108 old_value = handle(lookup.GetLazyValue(), isolate); 3109 if (is_observed) {
3109 old_attributes = lookup.GetAttributes(); 3110 // Function prototypes are stored specially
3111 if (self->IsJSFunction() &&
3112 JSFunction::cast(*self)->should_have_prototype() &&
3113 name->Equals(isolate->heap()->prototype_symbol())) {
3114 MaybeObject* maybe = Accessors::FunctionGetPrototype(*self, NULL);
3115 if (!maybe->ToHandle(&old_value, isolate)) return maybe;
rossberg 2012/12/05 12:02:29 I don't understand why this works. How come you do
adamk 2012/12/05 17:38:17 Hmm, I don't understand either. Added a test that
adamk 2012/12/05 19:47:38 Ah, here's why: there's that special case in %Defi
3116 } else {
3117 old_value = handle(lookup.GetLazyValue(), isolate);
3118 old_attributes = lookup.GetAttributes();
3119 }
3110 } 3120 }
3111 3121
3112 // Check of IsReadOnly removed from here in clone. 3122 // Check of IsReadOnly removed from here in clone.
3113 MaybeObject* result = *value; 3123 MaybeObject* result = *value;
3114 switch (lookup.type()) { 3124 switch (lookup.type()) {
3115 case NORMAL: { 3125 case NORMAL: {
3116 PropertyDetails details = PropertyDetails(attributes, NORMAL); 3126 PropertyDetails details = PropertyDetails(attributes, NORMAL);
3117 result = self->SetNormalizedProperty(*name, *value, details); 3127 result = self->SetNormalizedProperty(*name, *value, details);
3118 break; 3128 break;
3119 } 3129 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 break; 3172 break;
3163 } 3173 }
3164 case HANDLER: 3174 case HANDLER:
3165 case NONEXISTENT: 3175 case NONEXISTENT:
3166 UNREACHABLE(); 3176 UNREACHABLE();
3167 } 3177 }
3168 3178
3169 Handle<Object> hresult; 3179 Handle<Object> hresult;
3170 if (!result->ToHandle(&hresult, isolate)) return result; 3180 if (!result->ToHandle(&hresult, isolate)) return result;
3171 3181
3172 if (FLAG_harmony_observation && map()->is_observed()) { 3182 if (is_observed) {
3173 if (lookup.IsTransition()) { 3183 if (lookup.IsTransition()) {
3174 EnqueueChangeRecord(self, "new", name, old_value); 3184 EnqueueChangeRecord(self, "new", name, old_value);
3175 } else { 3185 } else {
3176 LookupResult new_lookup(isolate); 3186 LookupResult new_lookup(isolate);
3177 self->LocalLookup(*name, &new_lookup, true); 3187 self->LocalLookup(*name, &new_lookup, true);
3178 ASSERT(!new_lookup.GetLazyValue()->IsTheHole()); 3188 ASSERT(!new_lookup.GetLazyValue()->IsTheHole());
3179 if (old_value->IsTheHole() || 3189 if (old_value->IsTheHole() ||
3180 new_lookup.GetAttributes() != old_attributes) { 3190 new_lookup.GetAttributes() != old_attributes) {
3181 EnqueueChangeRecord(self, "reconfigured", name, old_value); 3191 EnqueueChangeRecord(self, "reconfigured", name, old_value);
3182 } else if (!new_lookup.GetLazyValue()->SameValue(*old_value)) { 3192 } else if (!new_lookup.GetLazyValue()->SameValue(*old_value)) {
(...skipping 10684 matching lines...) Expand 10 before | Expand all | Expand 10 after
13867 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13877 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13868 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13878 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13869 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13879 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13870 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13880 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13871 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13881 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13872 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13882 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13873 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13883 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13874 } 13884 }
13875 13885
13876 } } // namespace v8::internal 13886 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698