| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 namespace { | 212 namespace { |
| 213 | 213 |
| 214 Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, | 214 Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, |
| 215 Handle<Object> value) { | 215 Handle<Object> value) { |
| 216 // 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 |
| 217 // 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 |
| 218 // 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 |
| 219 // not the declaration context. | 219 // not the declaration context. |
| 220 // XXX module context??? |
| 220 Handle<Context> context_arg(isolate->context(), isolate); | 221 Handle<Context> context_arg(isolate->context(), isolate); |
| 221 Handle<Context> context(context_arg->declaration_context(), isolate); | 222 Handle<Context> context(context_arg->declaration_context(), isolate); |
| 222 | 223 |
| 223 DCHECK(context->IsFunctionContext() || context->IsNativeContext() || | 224 DCHECK(context->IsFunctionContext() || context->IsNativeContext() || |
| 224 context->IsScriptContext() || | 225 context->IsScriptContext() || |
| 225 (context->IsBlockContext() && context->has_extension())); | 226 (context->IsBlockContext() && context->has_extension())); |
| 226 | 227 |
| 227 bool is_function = value->IsJSFunction(); | 228 bool is_function = value->IsJSFunction(); |
| 228 bool is_var = !is_function; | 229 bool is_var = !is_function; |
| 229 DCHECK(!is_var || value->IsUndefined(isolate)); | 230 DCHECK(!is_var || value->IsUndefined(isolate)); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 DCHECK_EQ(2, args.length()); | 693 DCHECK_EQ(2, args.length()); |
| 693 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, extension_object, 0); | 694 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, extension_object, 0); |
| 694 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); | 695 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
| 695 Handle<Context> current(isolate->context()); | 696 Handle<Context> current(isolate->context()); |
| 696 Handle<Context> context = | 697 Handle<Context> context = |
| 697 isolate->factory()->NewWithContext(function, current, extension_object); | 698 isolate->factory()->NewWithContext(function, current, extension_object); |
| 698 isolate->set_context(*context); | 699 isolate->set_context(*context); |
| 699 return *context; | 700 return *context; |
| 700 } | 701 } |
| 701 | 702 |
| 703 RUNTIME_FUNCTION(Runtime_PushModuleContext) { |
| 704 HandleScope scope(isolate); |
| 705 DCHECK_EQ(3, args.length()); |
| 706 CONVERT_ARG_HANDLE_CHECKED(JSModule, module, 0); |
| 707 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
| 708 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 2); |
| 709 DCHECK(function->context() == isolate->context()); |
| 710 |
| 711 Handle<Context> context = |
| 712 isolate->factory()->NewModuleContext(module, function, scope_info); |
| 713 isolate->set_context(*context); |
| 714 return *context; |
| 715 } |
| 702 | 716 |
| 703 RUNTIME_FUNCTION(Runtime_PushCatchContext) { | 717 RUNTIME_FUNCTION(Runtime_PushCatchContext) { |
| 704 HandleScope scope(isolate); | 718 HandleScope scope(isolate); |
| 705 DCHECK_EQ(3, args.length()); | 719 DCHECK_EQ(3, args.length()); |
| 706 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 720 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 707 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); | 721 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
| 708 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); | 722 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); |
| 709 Handle<Context> current(isolate->context()); | 723 Handle<Context> current(isolate->context()); |
| 710 Handle<Context> context = isolate->factory()->NewCatchContext( | 724 Handle<Context> context = isolate->factory()->NewCatchContext( |
| 711 function, current, name, thrown_object); | 725 function, current, name, thrown_object); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { | 945 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { |
| 932 HandleScope scope(isolate); | 946 HandleScope scope(isolate); |
| 933 DCHECK_EQ(2, args.length()); | 947 DCHECK_EQ(2, args.length()); |
| 934 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 948 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 935 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 949 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| 936 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); | 950 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); |
| 937 } | 951 } |
| 938 | 952 |
| 939 } // namespace internal | 953 } // namespace internal |
| 940 } // namespace v8 | 954 } // namespace v8 |
| OLD | NEW |