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

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

Issue 1785403002: [runtime] split up loops with HandleScopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressing comment Created 4 years, 9 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-regexp.cc ('k') | src/runtime/runtime-strings.cc » ('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 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 HandleScope scope(isolate); 96 HandleScope scope(isolate);
97 DCHECK_EQ(2, args.length()); 97 DCHECK_EQ(2, args.length());
98 Handle<JSGlobalObject> global(isolate->global_object()); 98 Handle<JSGlobalObject> global(isolate->global_object());
99 Handle<Context> context(isolate->context()); 99 Handle<Context> context(isolate->context());
100 100
101 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0); 101 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0);
102 CONVERT_SMI_ARG_CHECKED(flags, 1); 102 CONVERT_SMI_ARG_CHECKED(flags, 1);
103 103
104 // Traverse the name/value pairs and set the properties. 104 // Traverse the name/value pairs and set the properties.
105 int length = pairs->length(); 105 int length = pairs->length();
106 for (int i = 0; i < length; i += 2) { 106 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 2, {
107 HandleScope scope(isolate);
108 Handle<String> name(String::cast(pairs->get(i))); 107 Handle<String> name(String::cast(pairs->get(i)));
109 Handle<Object> initial_value(pairs->get(i + 1), isolate); 108 Handle<Object> initial_value(pairs->get(i + 1), isolate);
110 109
111 // We have to declare a global const property. To capture we only 110 // We have to declare a global const property. To capture we only
112 // assign to it when evaluating the assignment for "const x = 111 // assign to it when evaluating the assignment for "const x =
113 // <expr>" the initial value is the hole. 112 // <expr>" the initial value is the hole.
114 bool is_var = initial_value->IsUndefined(); 113 bool is_var = initial_value->IsUndefined();
115 bool is_const = initial_value->IsTheHole(); 114 bool is_const = initial_value->IsTheHole();
116 bool is_function = initial_value->IsSharedFunctionInfo(); 115 bool is_function = initial_value->IsSharedFunctionInfo();
117 DCHECK_EQ(1, 116 DCHECK_EQ(1,
(...skipping 18 matching lines...) Expand all
136 bool is_eval = DeclareGlobalsEvalFlag::decode(flags); 135 bool is_eval = DeclareGlobalsEvalFlag::decode(flags);
137 int attr = NONE; 136 int attr = NONE;
138 if (is_const) attr |= READ_ONLY; 137 if (is_const) attr |= READ_ONLY;
139 if (is_function && is_native) attr |= READ_ONLY; 138 if (is_function && is_native) attr |= READ_ONLY;
140 if (!is_const && !is_eval) attr |= DONT_DELETE; 139 if (!is_const && !is_eval) attr |= DONT_DELETE;
141 140
142 Object* result = DeclareGlobals(isolate, global, name, value, 141 Object* result = DeclareGlobals(isolate, global, name, value,
143 static_cast<PropertyAttributes>(attr), 142 static_cast<PropertyAttributes>(attr),
144 is_var, is_const, is_function); 143 is_var, is_const, is_function);
145 if (isolate->has_pending_exception()) return result; 144 if (isolate->has_pending_exception()) return result;
146 } 145 });
147 146
148 return isolate->heap()->undefined_value(); 147 return isolate->heap()->undefined_value();
149 } 148 }
150 149
151 150
152 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { 151 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) {
153 HandleScope scope(isolate); 152 HandleScope scope(isolate);
154 // args[0] == name 153 // args[0] == name
155 // args[1] == language_mode 154 // args[1] == language_mode
156 // args[2] == value (optional) 155 // args[2] == value (optional)
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 DCHECK_EQ(2, args.length()); 1134 DCHECK_EQ(2, args.length());
1136 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 1135 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
1137 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 1136 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
1138 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, 1137 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
1139 StoreLookupSlot(name, value, STRICT)); 1138 StoreLookupSlot(name, value, STRICT));
1140 return *value; 1139 return *value;
1141 } 1140 }
1142 1141
1143 } // namespace internal 1142 } // namespace internal
1144 } // namespace v8 1143 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-regexp.cc ('k') | src/runtime/runtime-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698