OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8836 MaybeObject* maybe_context = | 8836 MaybeObject* maybe_context = |
8837 isolate->heap()->AllocateBlockContext(function, | 8837 isolate->heap()->AllocateBlockContext(function, |
8838 isolate->context(), | 8838 isolate->context(), |
8839 scope_info); | 8839 scope_info); |
8840 if (!maybe_context->To(&context)) return maybe_context; | 8840 if (!maybe_context->To(&context)) return maybe_context; |
8841 isolate->set_context(context); | 8841 isolate->set_context(context); |
8842 return context; | 8842 return context; |
8843 } | 8843 } |
8844 | 8844 |
8845 | 8845 |
| 8846 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { |
| 8847 ASSERT(args.length() == 1); |
| 8848 Object* obj = args[0]; |
| 8849 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
| 8850 } |
| 8851 |
| 8852 |
8846 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) { | 8853 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) { |
8847 NoHandleAllocation ha; | 8854 NoHandleAllocation ha; |
8848 ASSERT(args.length() == 2); | 8855 ASSERT(args.length() == 1); |
8849 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 0); | 8856 CONVERT_ARG_HANDLE_CHECKED(JSModule, instance, 0); |
8850 CONVERT_ARG_HANDLE_CHECKED(JSModule, instance, 1); | |
8851 | 8857 |
8852 Context* context; | 8858 Context* context = Context::cast(instance->context()); |
8853 MaybeObject* maybe_context = | 8859 Context* previous = isolate->context(); |
8854 isolate->heap()->AllocateModuleContext(isolate->context(), | 8860 ASSERT(context->IsModuleContext()); |
8855 scope_info); | 8861 // Initialize the context links. |
8856 if (!maybe_context->To(&context)) return maybe_context; | 8862 context->set_previous(previous); |
8857 // Also initialize the context slot of the instance object. | 8863 context->set_closure(previous->closure()); |
8858 instance->set_context(context); | 8864 context->set_global(previous->global()); |
8859 isolate->set_context(context); | 8865 isolate->set_context(context); |
8860 | 8866 |
8861 return context; | 8867 return context; |
8862 } | 8868 } |
8863 | 8869 |
8864 | 8870 |
8865 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { | 8871 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { |
8866 HandleScope scope(isolate); | 8872 HandleScope scope(isolate); |
8867 ASSERT(args.length() == 2); | 8873 ASSERT(args.length() == 2); |
8868 | 8874 |
(...skipping 4836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13705 // Handle last resort GC and make sure to allow future allocations | 13711 // Handle last resort GC and make sure to allow future allocations |
13706 // to grow the heap without causing GCs (if possible). | 13712 // to grow the heap without causing GCs (if possible). |
13707 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13713 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13708 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13714 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13709 "Runtime::PerformGC"); | 13715 "Runtime::PerformGC"); |
13710 } | 13716 } |
13711 } | 13717 } |
13712 | 13718 |
13713 | 13719 |
13714 } } // namespace v8::internal | 13720 } } // namespace v8::internal |
OLD | NEW |