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

Side by Side Diff: src/runtime/runtime-scopes.cc

Issue 1667083002: Reland of [runtime] further dismantle AccessorInfoHandling, reducing it to the single API usecase. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months 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/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 DCHECK(is_function); 59 DCHECK(is_function);
60 if ((old_attributes & DONT_DELETE) != 0) { 60 if ((old_attributes & DONT_DELETE) != 0) {
61 // Only allow reconfiguring globals to functions in user code (no 61 // Only allow reconfiguring globals to functions in user code (no
62 // natives, which are marked as read-only). 62 // natives, which are marked as read-only).
63 DCHECK((attr & READ_ONLY) == 0); 63 DCHECK((attr & READ_ONLY) == 0);
64 64
65 // Check whether we can reconfigure the existing property into a 65 // Check whether we can reconfigure the existing property into a
66 // function. 66 // function.
67 PropertyDetails old_details = it.property_details(); 67 PropertyDetails old_details = it.property_details();
68 // TODO(verwaest): ACCESSOR_CONSTANT invalidly includes
69 // ExecutableAccessInfo,
70 // which are actually data properties, not accessor properties.
71 if (old_details.IsReadOnly() || old_details.IsDontEnum() || 68 if (old_details.IsReadOnly() || old_details.IsDontEnum() ||
72 old_details.type() == ACCESSOR_CONSTANT) { 69 (it.state() == LookupIterator::ACCESSOR &&
70 it.GetAccessors()->IsAccessorPair())) {
73 return ThrowRedeclarationError(isolate, name); 71 return ThrowRedeclarationError(isolate, name);
74 } 72 }
75 // If the existing property is not configurable, keep its attributes. Do 73 // If the existing property is not configurable, keep its attributes. Do
76 attr = old_attributes; 74 attr = old_attributes;
77 } 75 }
76
77 // If the current state is ACCESSOR, this could mean it's an AccessorInfo
78 // type property. We are not allowed to call into such setters during global
79 // function declaration since this would break e.g., onload. Meaning
80 // 'function onload() {}' would invalidly register that function as the
81 // onload callback. To avoid this situation, we first delete the property
82 // before readding it as a regular data property below.
83 if (it.state() == LookupIterator::ACCESSOR) it.Delete();
78 } 84 }
79 85
80 // Define or redefine own property. 86 // Define or redefine own property.
81 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( 87 RETURN_FAILURE_ON_EXCEPTION(
82 global, name, value, attr)); 88 isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr));
83 89
84 return isolate->heap()->undefined_value(); 90 return isolate->heap()->undefined_value();
85 } 91 }
86 92
87 93
88 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { 94 RUNTIME_FUNCTION(Runtime_DeclareGlobals) {
89 HandleScope scope(isolate); 95 HandleScope scope(isolate);
90 DCHECK_EQ(2, args.length()); 96 DCHECK_EQ(2, args.length());
91 Handle<JSGlobalObject> global(isolate->global_object()); 97 Handle<JSGlobalObject> global(isolate->global_object());
92 Handle<Context> context(isolate->context()); 98 Handle<Context> context(isolate->context());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Ignore if we can't reconfigure the value. 195 // Ignore if we can't reconfigure the value.
190 if ((old_attributes & DONT_DELETE) != 0) { 196 if ((old_attributes & DONT_DELETE) != 0) {
191 if ((old_attributes & READ_ONLY) != 0 || 197 if ((old_attributes & READ_ONLY) != 0 ||
192 it.state() == LookupIterator::ACCESSOR) { 198 it.state() == LookupIterator::ACCESSOR) {
193 return *value; 199 return *value;
194 } 200 }
195 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY); 201 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY);
196 } 202 }
197 } 203 }
198 204
199 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( 205 RETURN_FAILURE_ON_EXCEPTION(
200 global, name, value, attr)); 206 isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr));
201 207
202 return *value; 208 return *value;
203 } 209 }
204 210
205 211
206 namespace { 212 namespace {
207 213
208 Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name, 214 Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name,
209 Handle<Object> initial_value, 215 Handle<Object> initial_value,
210 PropertyAttributes attr) { 216 PropertyAttributes attr) {
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 1252
1247 // Lookup in the initial Object.prototype object. 1253 // Lookup in the initial Object.prototype object.
1248 Handle<Object> result; 1254 Handle<Object> result;
1249 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1255 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1250 isolate, result, 1256 isolate, result,
1251 Object::GetProperty(isolate->initial_object_prototype(), key)); 1257 Object::GetProperty(isolate->initial_object_prototype(), key));
1252 return *result; 1258 return *result;
1253 } 1259 }
1254 } // namespace internal 1260 } // namespace internal
1255 } // namespace v8 1261 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698