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 8731 matching lines...) Loading... |
8742 NoHandleAllocation ha; | 8742 NoHandleAllocation ha; |
8743 ASSERT(args.length() == 2); | 8743 ASSERT(args.length() == 2); |
8744 | 8744 |
8745 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8745 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
8746 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); | 8746 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); |
8747 Context* result; | 8747 Context* result; |
8748 MaybeObject* maybe_result = | 8748 MaybeObject* maybe_result = |
8749 isolate->heap()->AllocateGlobalContext(function, scope_info); | 8749 isolate->heap()->AllocateGlobalContext(function, scope_info); |
8750 if (!maybe_result->To(&result)) return maybe_result; | 8750 if (!maybe_result->To(&result)) return maybe_result; |
8751 | 8751 |
| 8752 ASSERT(function->context() == isolate->context()); |
| 8753 ASSERT(function->context()->global_object() == result->global_object()); |
8752 isolate->set_context(result); | 8754 isolate->set_context(result); |
| 8755 result->global_object()->set_global_context(result); |
8753 | 8756 |
8754 return result; // non-failure | 8757 return result; // non-failure |
8755 } | 8758 } |
8756 | 8759 |
8757 | 8760 |
8758 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { | 8761 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { |
8759 NoHandleAllocation ha; | 8762 NoHandleAllocation ha; |
8760 ASSERT(args.length() == 1); | 8763 ASSERT(args.length() == 1); |
8761 | 8764 |
8762 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8765 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
(...skipping 2502 matching lines...) Loading... |
11265 // Check whether we are in global, eval or function code. | 11268 // Check whether we are in global, eval or function code. |
11266 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 11269 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
11267 if (scope_info->Type() != FUNCTION_SCOPE) { | 11270 if (scope_info->Type() != FUNCTION_SCOPE) { |
11268 // Global or eval code. | 11271 // Global or eval code. |
11269 CompilationInfoWithZone info(script); | 11272 CompilationInfoWithZone info(script); |
11270 if (scope_info->Type() == GLOBAL_SCOPE) { | 11273 if (scope_info->Type() == GLOBAL_SCOPE) { |
11271 info.MarkAsGlobal(); | 11274 info.MarkAsGlobal(); |
11272 } else { | 11275 } else { |
11273 ASSERT(scope_info->Type() == EVAL_SCOPE); | 11276 ASSERT(scope_info->Type() == EVAL_SCOPE); |
11274 info.MarkAsEval(); | 11277 info.MarkAsEval(); |
11275 info.SetCallingContext(Handle<Context>(function_->context())); | 11278 info.SetContext(Handle<Context>(function_->context())); |
11276 } | 11279 } |
11277 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { | 11280 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { |
11278 scope = info.function()->scope(); | 11281 scope = info.function()->scope(); |
11279 } | 11282 } |
11280 RetrieveScopeChain(scope, shared_info); | 11283 RetrieveScopeChain(scope, shared_info); |
11281 } else { | 11284 } else { |
11282 // Function code | 11285 // Function code |
11283 CompilationInfoWithZone info(shared_info); | 11286 CompilationInfoWithZone info(shared_info); |
11284 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { | 11287 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { |
11285 scope = info.function()->scope(); | 11288 scope = info.function()->scope(); |
(...skipping 2449 matching lines...) Loading... |
13735 // Handle last resort GC and make sure to allow future allocations | 13738 // Handle last resort GC and make sure to allow future allocations |
13736 // to grow the heap without causing GCs (if possible). | 13739 // to grow the heap without causing GCs (if possible). |
13737 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13740 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13738 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13741 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13739 "Runtime::PerformGC"); | 13742 "Runtime::PerformGC"); |
13740 } | 13743 } |
13741 } | 13744 } |
13742 | 13745 |
13743 | 13746 |
13744 } } // namespace v8::internal | 13747 } } // namespace v8::internal |
OLD | NEW |