OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // named interceptor or the interceptor is not masking. | 123 // named interceptor or the interceptor is not masking. |
124 if (!global->HasNamedInterceptor() || | 124 if (!global->HasNamedInterceptor() || |
125 global->GetNamedInterceptor()->non_masking()) { | 125 global->GetNamedInterceptor()->non_masking()) { |
126 LoadGlobalICNexus nexus(feedback_vector, slot); | 126 LoadGlobalICNexus nexus(feedback_vector, slot); |
127 nexus.ConfigurePropertyCellMode(it.GetPropertyCell()); | 127 nexus.ConfigurePropertyCellMode(it.GetPropertyCell()); |
128 } | 128 } |
129 } | 129 } |
130 return isolate->heap()->undefined_value(); | 130 return isolate->heap()->undefined_value(); |
131 } | 131 } |
132 | 132 |
133 Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> pairs, int flags, | 133 Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations, |
134 Handle<TypeFeedbackVector> feedback_vector) { | 134 int flags, Handle<TypeFeedbackVector> feedback_vector) { |
135 HandleScope scope(isolate); | 135 HandleScope scope(isolate); |
136 Handle<JSGlobalObject> global(isolate->global_object()); | 136 Handle<JSGlobalObject> global(isolate->global_object()); |
137 Handle<Context> context(isolate->context()); | 137 Handle<Context> context(isolate->context()); |
138 | 138 |
139 // Traverse the name/value pairs and set the properties. | 139 // Traverse the name/value pairs and set the properties. |
140 int length = pairs->length(); | 140 int length = declarations->length(); |
141 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 2, { | 141 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 3, { |
142 FeedbackVectorSlot slot(Smi::cast(pairs->get(i))->value()); | 142 Handle<String> name(String::cast(declarations->get(i)), isolate); |
143 Handle<String> name(feedback_vector->GetName(slot), isolate); | 143 FeedbackVectorSlot slot(Smi::cast(declarations->get(i + 1))->value()); |
144 Handle<Object> initial_value(pairs->get(i + 1), isolate); | 144 Handle<Object> initial_value(declarations->get(i + 2), isolate); |
145 | 145 |
146 bool is_var = initial_value->IsUndefined(isolate); | 146 bool is_var = initial_value->IsUndefined(isolate); |
147 bool is_function = initial_value->IsSharedFunctionInfo(); | 147 bool is_function = initial_value->IsSharedFunctionInfo(); |
148 DCHECK_EQ(1, BoolToInt(is_var) + BoolToInt(is_function)); | 148 DCHECK_EQ(1, BoolToInt(is_var) + BoolToInt(is_function)); |
149 | 149 |
150 Handle<Object> value; | 150 Handle<Object> value; |
151 if (is_function) { | 151 if (is_function) { |
152 // Copy the function and update its context. Use it as value. | 152 // Copy the function and update its context. Use it as value. |
153 Handle<SharedFunctionInfo> shared = | 153 Handle<SharedFunctionInfo> shared = |
154 Handle<SharedFunctionInfo>::cast(initial_value); | 154 Handle<SharedFunctionInfo>::cast(initial_value); |
(...skipping 24 matching lines...) Expand all Loading... |
179 | 179 |
180 return isolate->heap()->undefined_value(); | 180 return isolate->heap()->undefined_value(); |
181 } | 181 } |
182 | 182 |
183 } // namespace | 183 } // namespace |
184 | 184 |
185 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { | 185 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { |
186 HandleScope scope(isolate); | 186 HandleScope scope(isolate); |
187 DCHECK_EQ(3, args.length()); | 187 DCHECK_EQ(3, args.length()); |
188 | 188 |
189 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0); | 189 CONVERT_ARG_HANDLE_CHECKED(FixedArray, declarations, 0); |
190 CONVERT_SMI_ARG_CHECKED(flags, 1); | 190 CONVERT_SMI_ARG_CHECKED(flags, 1); |
191 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, feedback_vector, 2); | 191 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, feedback_vector, 2); |
192 | 192 |
193 return DeclareGlobals(isolate, pairs, flags, feedback_vector); | 193 return DeclareGlobals(isolate, declarations, flags, feedback_vector); |
194 } | 194 } |
195 | 195 |
196 // TODO(ishell): merge this with Runtime::kDeclareGlobals once interpreter | 196 // TODO(ishell): merge this with Runtime::kDeclareGlobals once interpreter |
197 // is able to pass feedback vector. | 197 // is able to pass feedback vector. |
198 RUNTIME_FUNCTION(Runtime_DeclareGlobalsForInterpreter) { | 198 RUNTIME_FUNCTION(Runtime_DeclareGlobalsForInterpreter) { |
199 HandleScope scope(isolate); | 199 HandleScope scope(isolate); |
200 DCHECK_EQ(3, args.length()); | 200 DCHECK_EQ(3, args.length()); |
201 | 201 |
202 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 0); | 202 CONVERT_ARG_HANDLE_CHECKED(FixedArray, declarations, 0); |
203 CONVERT_SMI_ARG_CHECKED(flags, 1); | 203 CONVERT_SMI_ARG_CHECKED(flags, 1); |
204 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 2); | 204 CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 2); |
205 | 205 |
206 Handle<TypeFeedbackVector> feedback_vector(closure->feedback_vector(), | 206 Handle<TypeFeedbackVector> feedback_vector(closure->feedback_vector(), |
207 isolate); | 207 isolate); |
208 return DeclareGlobals(isolate, pairs, flags, feedback_vector); | 208 return DeclareGlobals(isolate, declarations, flags, feedback_vector); |
209 } | 209 } |
210 | 210 |
211 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { | 211 RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) { |
212 HandleScope scope(isolate); | 212 HandleScope scope(isolate); |
213 DCHECK_EQ(3, args.length()); | 213 DCHECK_EQ(3, args.length()); |
214 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 214 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
215 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1); | 215 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1); |
216 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 216 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
217 | 217 |
218 Handle<JSGlobalObject> global(isolate->global_object()); | 218 Handle<JSGlobalObject> global(isolate->global_object()); |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { | 957 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { |
958 HandleScope scope(isolate); | 958 HandleScope scope(isolate); |
959 DCHECK_EQ(2, args.length()); | 959 DCHECK_EQ(2, args.length()); |
960 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 960 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
961 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 961 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
962 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); | 962 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); |
963 } | 963 } |
964 | 964 |
965 } // namespace internal | 965 } // namespace internal |
966 } // namespace v8 | 966 } // namespace v8 |
OLD | NEW |