| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 HandleScope scope(isolate); | 625 HandleScope scope(isolate); |
| 626 DCHECK(args.length() == 2); | 626 DCHECK(args.length() == 2); |
| 627 | 627 |
| 628 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 628 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 629 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); | 629 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
| 630 Handle<GlobalObject> global_object(function->context()->global_object()); | 630 Handle<GlobalObject> global_object(function->context()->global_object()); |
| 631 Handle<Context> native_context(global_object->native_context()); | 631 Handle<Context> native_context(global_object->native_context()); |
| 632 Handle<ScriptContextTable> script_context_table( | 632 Handle<ScriptContextTable> script_context_table( |
| 633 native_context->script_context_table()); | 633 native_context->script_context_table()); |
| 634 | 634 |
| 635 Handle<String> clashed_name; | |
| 636 Object* name_clash_result = | 635 Object* name_clash_result = |
| 637 FindNameClash(scope_info, global_object, script_context_table); | 636 FindNameClash(scope_info, global_object, script_context_table); |
| 638 if (isolate->has_pending_exception()) return name_clash_result; | 637 if (isolate->has_pending_exception()) return name_clash_result; |
| 639 | 638 |
| 640 // Script contexts have a canonical empty function as their closure, not the | 639 // Script contexts have a canonical empty function as their closure, not the |
| 641 // anonymous closure containing the global code. See | 640 // anonymous closure containing the global code. See |
| 642 // FullCodeGenerator::PushFunctionArgumentForContextAllocation. | 641 // FullCodeGenerator::PushFunctionArgumentForContextAllocation. |
| 643 Handle<JSFunction> closure(native_context->closure()); | 642 Handle<JSFunction> closure(global_object->IsJSBuiltinsObject() |
| 643 ? *function |
| 644 : native_context->closure()); |
| 644 Handle<Context> result = | 645 Handle<Context> result = |
| 645 isolate->factory()->NewScriptContext(closure, scope_info); | 646 isolate->factory()->NewScriptContext(closure, scope_info); |
| 646 | 647 |
| 648 result->InitializeGlobalSlots(); |
| 649 |
| 647 DCHECK(function->context() == isolate->context()); | 650 DCHECK(function->context() == isolate->context()); |
| 648 DCHECK(function->context()->global_object() == result->global_object()); | 651 DCHECK(*global_object == result->global_object()); |
| 649 | 652 |
| 650 Handle<ScriptContextTable> new_script_context_table = | 653 Handle<ScriptContextTable> new_script_context_table = |
| 651 ScriptContextTable::Extend(script_context_table, result); | 654 ScriptContextTable::Extend(script_context_table, result); |
| 652 native_context->set_script_context_table(*new_script_context_table); | 655 native_context->set_script_context_table(*new_script_context_table); |
| 653 return *result; | 656 return *result; |
| 654 } | 657 } |
| 655 | 658 |
| 656 | 659 |
| 657 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { | 660 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { |
| 658 HandleScope scope(isolate); | 661 HandleScope scope(isolate); |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 return Smi::FromInt(frame->GetArgumentsLength()); | 1132 return Smi::FromInt(frame->GetArgumentsLength()); |
| 1130 } | 1133 } |
| 1131 | 1134 |
| 1132 | 1135 |
| 1133 RUNTIME_FUNCTION(Runtime_Arguments) { | 1136 RUNTIME_FUNCTION(Runtime_Arguments) { |
| 1134 SealHandleScope shs(isolate); | 1137 SealHandleScope shs(isolate); |
| 1135 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 1138 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
| 1136 } | 1139 } |
| 1137 } // namespace internal | 1140 } // namespace internal |
| 1138 } // namespace v8 | 1141 } // namespace v8 |
| OLD | NEW |