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

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

Issue 2219223002: Remove more vestigial CONST_LEGACY support and clean up var declaration code (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/runtime/runtime.h ('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 <memory> 7 #include <memory>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 DCHECK_EQ(3, args.length()); 202 DCHECK_EQ(3, args.length());
203 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 203 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
204 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1); 204 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1);
205 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 205 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
206 206
207 Handle<JSGlobalObject> global(isolate->global_object()); 207 Handle<JSGlobalObject> global(isolate->global_object());
208 RETURN_RESULT_OR_FAILURE( 208 RETURN_RESULT_OR_FAILURE(
209 isolate, Object::SetProperty(global, name, value, language_mode)); 209 isolate, Object::SetProperty(global, name, value, language_mode));
210 } 210 }
211 211
212
213 RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) {
214 HandleScope handle_scope(isolate);
215 DCHECK_EQ(2, args.length());
216 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
217 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
218
219 Handle<JSGlobalObject> global(isolate->global_object());
220
221 // Lookup the property as own on the global object.
222 LookupIterator it(global, name, global, LookupIterator::OWN_SKIP_INTERCEPTOR);
223 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
224 DCHECK(maybe.IsJust());
225 PropertyAttributes old_attributes = maybe.FromJust();
226
227 PropertyAttributes attr =
228 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
229 // Set the value if the property is either missing, or the property attributes
230 // allow setting the value without invoking an accessor.
231 if (it.IsFound()) {
232 // Ignore if we can't reconfigure the value.
233 if ((old_attributes & DONT_DELETE) != 0) {
234 if ((old_attributes & READ_ONLY) != 0 ||
235 it.state() == LookupIterator::ACCESSOR) {
236 return *value;
237 }
238 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY);
239 }
240 }
241
242 RETURN_FAILURE_ON_EXCEPTION(
243 isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr));
244
245 return *value;
246 }
247
248 namespace { 212 namespace {
249 213
250 Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, 214 Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
251 Handle<Object> value) { 215 Handle<Object> value) {
252 // Declarations are always made in a function, native, or script context, or 216 // Declarations are always made in a function, native, or script context, or
253 // a declaration block scope. Since this is called from eval, the context 217 // a declaration block scope. Since this is called from eval, the context
254 // passed is the context of the caller, which may be some nested context and 218 // passed is the context of the caller, which may be some nested context and
255 // not the declaration context. 219 // not the declaration context.
256 Handle<Context> context_arg(isolate->context(), isolate); 220 Handle<Context> context_arg(isolate->context(), isolate);
257 Handle<Context> context(context_arg->declaration_context(), isolate); 221 Handle<Context> context(context_arg->declaration_context(), isolate);
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { 933 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) {
970 HandleScope scope(isolate); 934 HandleScope scope(isolate);
971 DCHECK_EQ(2, args.length()); 935 DCHECK_EQ(2, args.length());
972 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 936 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
973 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 937 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
974 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); 938 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT));
975 } 939 }
976 940
977 } // namespace internal 941 } // namespace internal
978 } // namespace v8 942 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698