1 // Copyright 2016 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "src/runtime/runtime-utils.h" 6 7 #include "src/arguments.h" 8 9 namespace v8 { 10 namespace internal { 11 12 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) { 13 HandleScope scope(isolate); 14 DCHECK(args.length() == 1); 15 CONVERT_SMI_ARG_CHECKED(module_request, 0); 16 Handle<Module> module(isolate->context()->module()); 17 return *Module::GetModuleNamespace(module, module_request); 18 } 19 20 RUNTIME_FUNCTION(Runtime_LoadModuleVariable) { 21 HandleScope scope(isolate); 22 DCHECK(args.length() == 1); 23 CONVERT_SMI_ARG_CHECKED(index, 0); 24 Handle<Module> module(isolate->context()->module()); 25 return *Module::LoadVariable(module, index); 26 } 27 28 RUNTIME_FUNCTION(Runtime_StoreModuleVariable) { 29 HandleScope scope(isolate); 30 DCHECK(args.length() == 2); 31 CONVERT_SMI_ARG_CHECKED(index, 0); 32 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 33 Handle<Module> module(isolate->context()->module()); 34 Module::StoreVariable(module, index, value); 35 return isolate->heap()->undefined_value(); 36 } 37 38 } // namespace internal 39 } // namespace v8 40