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

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

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: relax dchecks Created 4 years, 1 month 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 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, 225 Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
226 Handle<Object> value) { 226 Handle<Object> value) {
227 // Declarations are always made in a function, native, or script context, or 227 // Declarations are always made in a function, native, or script context, or
228 // a declaration block scope. Since this is called from eval, the context 228 // a declaration block scope. Since this is called from eval, the context
229 // passed is the context of the caller, which may be some nested context and 229 // passed is the context of the caller, which may be some nested context and
230 // not the declaration context. 230 // not the declaration context.
231 Handle<Context> context_arg(isolate->context(), isolate); 231 Handle<Context> context_arg(isolate->context(), isolate);
232 Handle<Context> context(context_arg->declaration_context(), isolate); 232 Handle<Context> context(context_arg->declaration_context(), isolate);
233 233
234 DCHECK(context->IsFunctionContext() || context->IsNativeContext() || 234 DCHECK(context->IsFunctionContext() || context->IsNativeContext() ||
235 context->IsScriptContext() || 235 context->IsScriptContext() || context->IsEvalContext() ||
236 (context->IsBlockContext() && context->has_extension())); 236 (context->IsBlockContext() && context->has_extension()));
237 237
238 bool is_function = value->IsJSFunction(); 238 bool is_function = value->IsJSFunction();
239 bool is_var = !is_function; 239 bool is_var = !is_function;
240 DCHECK(!is_var || value->IsUndefined(isolate)); 240 DCHECK(!is_var || value->IsUndefined(isolate));
241 241
242 int index; 242 int index;
243 PropertyAttributes attributes; 243 PropertyAttributes attributes;
244 InitializationFlag init_flag; 244 InitializationFlag init_flag;
245 VariableMode mode; 245 VariableMode mode;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 object = isolate->factory()->NewJSObject( 306 object = isolate->factory()->NewJSObject(
307 isolate->context_extension_function()); 307 isolate->context_extension_function());
308 Handle<HeapObject> extension = isolate->factory()->NewContextExtension( 308 Handle<HeapObject> extension = isolate->factory()->NewContextExtension(
309 handle(context->scope_info()), object); 309 handle(context->scope_info()), object);
310 context->set_extension(*extension); 310 context->set_extension(*extension);
311 } else { 311 } else {
312 object = handle(context->extension_object(), isolate); 312 object = handle(context->extension_object(), isolate);
313 } 313 }
314 DCHECK(object->IsJSContextExtensionObject() || object->IsJSGlobalObject()); 314 DCHECK(object->IsJSContextExtensionObject() || object->IsJSGlobalObject());
315 } else { 315 } else {
316 DCHECK(context->IsFunctionContext()); 316 DCHECK(context->IsFunctionContext() || context->IsEvalContext());
adamk 2016/11/12 00:26:05 We should never get here for an eval context, sinc
Dan Ehrenberg 2016/12/07 05:41:26 Reverted and added a comment explaining the DCHECK
317 object = 317 object =
318 isolate->factory()->NewJSObject(isolate->context_extension_function()); 318 isolate->factory()->NewJSObject(isolate->context_extension_function());
319 context->set_extension(*object); 319 context->set_extension(*object);
320 } 320 }
321 321
322 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( 322 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
323 object, name, value, NONE)); 323 object, name, value, NONE));
324 324
325 return isolate->heap()->undefined_value(); 325 return isolate->heap()->undefined_value();
326 } 326 }
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 HandleScope scope(isolate); 689 HandleScope scope(isolate);
690 DCHECK(args.length() == 1); 690 DCHECK(args.length() == 1);
691 691
692 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 692 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
693 693
694 DCHECK(function->context() == isolate->context()); 694 DCHECK(function->context() == isolate->context());
695 int length = function->shared()->scope_info()->ContextLength(); 695 int length = function->shared()->scope_info()->ContextLength();
696 return *isolate->factory()->NewFunctionContext(length, function); 696 return *isolate->factory()->NewFunctionContext(length, function);
697 } 697 }
698 698
699 RUNTIME_FUNCTION(Runtime_NewEvalContext) {
700 HandleScope scope(isolate);
701 DCHECK(args.length() == 1);
702
703 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
704
705 DCHECK(function->context() == isolate->context());
706 int length = function->shared()->scope_info()->ContextLength();
707 return *isolate->factory()->NewEvalContext(length, function);
708 }
699 709
700 RUNTIME_FUNCTION(Runtime_PushWithContext) { 710 RUNTIME_FUNCTION(Runtime_PushWithContext) {
701 HandleScope scope(isolate); 711 HandleScope scope(isolate);
702 DCHECK_EQ(3, args.length()); 712 DCHECK_EQ(3, args.length());
703 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, extension_object, 0); 713 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, extension_object, 0);
704 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); 714 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1);
705 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); 715 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2);
706 Handle<Context> current(isolate->context()); 716 Handle<Context> current(isolate->context());
707 Handle<Context> context = isolate->factory()->NewWithContext( 717 Handle<Context> context = isolate->factory()->NewWithContext(
708 function, current, scope_info, extension_object); 718 function, current, scope_info, extension_object);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { 966 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) {
957 HandleScope scope(isolate); 967 HandleScope scope(isolate);
958 DCHECK_EQ(2, args.length()); 968 DCHECK_EQ(2, args.length());
959 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 969 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
960 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 970 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
961 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); 971 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT));
962 } 972 }
963 973
964 } // namespace internal 974 } // namespace internal
965 } // namespace v8 975 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698