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 10637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10648 Handle<JSObject> scope_object) { | 10648 Handle<JSObject> scope_object) { |
10649 // Fill all context locals to the context extension. | 10649 // Fill all context locals to the context extension. |
10650 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { | 10650 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { |
10651 VariableMode mode; | 10651 VariableMode mode; |
10652 InitializationFlag init_flag; | 10652 InitializationFlag init_flag; |
10653 int context_index = scope_info->ContextSlotIndex( | 10653 int context_index = scope_info->ContextSlotIndex( |
10654 scope_info->ContextLocalName(i), &mode, &init_flag); | 10654 scope_info->ContextLocalName(i), &mode, &init_flag); |
10655 | 10655 |
10656 RETURN_IF_EMPTY_HANDLE_VALUE( | 10656 RETURN_IF_EMPTY_HANDLE_VALUE( |
10657 isolate, | 10657 isolate, |
10658 SetProperty(scope_object, | 10658 SetProperty(isolate, |
| 10659 scope_object, |
10659 Handle<String>(scope_info->ContextLocalName(i)), | 10660 Handle<String>(scope_info->ContextLocalName(i)), |
10660 Handle<Object>(context->get(context_index), isolate), | 10661 Handle<Object>(context->get(context_index), isolate), |
10661 NONE, | 10662 NONE, |
10662 kNonStrictMode), | 10663 kNonStrictMode), |
10663 false); | 10664 false); |
10664 } | 10665 } |
10665 | 10666 |
10666 return true; | 10667 return true; |
10667 } | 10668 } |
10668 | 10669 |
(...skipping 14 matching lines...) Expand all Loading... |
10683 isolate->factory()->NewJSObject(isolate->object_function()); | 10684 isolate->factory()->NewJSObject(isolate->object_function()); |
10684 | 10685 |
10685 // First fill all parameters. | 10686 // First fill all parameters. |
10686 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 10687 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
10687 Handle<Object> value( | 10688 Handle<Object> value( |
10688 i < frame_inspector->GetParametersCount() ? | 10689 i < frame_inspector->GetParametersCount() ? |
10689 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value()); | 10690 frame_inspector->GetParameter(i) : isolate->heap()->undefined_value()); |
10690 | 10691 |
10691 RETURN_IF_EMPTY_HANDLE_VALUE( | 10692 RETURN_IF_EMPTY_HANDLE_VALUE( |
10692 isolate, | 10693 isolate, |
10693 SetProperty(local_scope, | 10694 SetProperty(isolate, |
| 10695 local_scope, |
10694 Handle<String>(scope_info->ParameterName(i)), | 10696 Handle<String>(scope_info->ParameterName(i)), |
10695 value, | 10697 value, |
10696 NONE, | 10698 NONE, |
10697 kNonStrictMode), | 10699 kNonStrictMode), |
10698 Handle<JSObject>()); | 10700 Handle<JSObject>()); |
10699 } | 10701 } |
10700 | 10702 |
10701 // Second fill all stack locals. | 10703 // Second fill all stack locals. |
10702 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 10704 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
10703 RETURN_IF_EMPTY_HANDLE_VALUE( | 10705 RETURN_IF_EMPTY_HANDLE_VALUE( |
10704 isolate, | 10706 isolate, |
10705 SetProperty(local_scope, | 10707 SetProperty(isolate, |
| 10708 local_scope, |
10706 Handle<String>(scope_info->StackLocalName(i)), | 10709 Handle<String>(scope_info->StackLocalName(i)), |
10707 Handle<Object>(frame_inspector->GetExpression(i)), | 10710 Handle<Object>(frame_inspector->GetExpression(i)), |
10708 NONE, | 10711 NONE, |
10709 kNonStrictMode), | 10712 kNonStrictMode), |
10710 Handle<JSObject>()); | 10713 Handle<JSObject>()); |
10711 } | 10714 } |
10712 | 10715 |
10713 if (scope_info->HasContext()) { | 10716 if (scope_info->HasContext()) { |
10714 // Third fill all context locals. | 10717 // Third fill all context locals. |
10715 Handle<Context> frame_context(Context::cast(frame->context())); | 10718 Handle<Context> frame_context(Context::cast(frame->context())); |
(...skipping 13 matching lines...) Expand all Loading... |
10729 Handle<FixedArray> keys = | 10732 Handle<FixedArray> keys = |
10730 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 10733 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
10731 if (threw) return Handle<JSObject>(); | 10734 if (threw) return Handle<JSObject>(); |
10732 | 10735 |
10733 for (int i = 0; i < keys->length(); i++) { | 10736 for (int i = 0; i < keys->length(); i++) { |
10734 // Names of variables introduced by eval are strings. | 10737 // Names of variables introduced by eval are strings. |
10735 ASSERT(keys->get(i)->IsString()); | 10738 ASSERT(keys->get(i)->IsString()); |
10736 Handle<String> key(String::cast(keys->get(i))); | 10739 Handle<String> key(String::cast(keys->get(i))); |
10737 RETURN_IF_EMPTY_HANDLE_VALUE( | 10740 RETURN_IF_EMPTY_HANDLE_VALUE( |
10738 isolate, | 10741 isolate, |
10739 SetProperty(local_scope, | 10742 SetProperty(isolate, |
| 10743 local_scope, |
10740 key, | 10744 key, |
10741 GetProperty(ext, key), | 10745 GetProperty(ext, key), |
10742 NONE, | 10746 NONE, |
10743 kNonStrictMode), | 10747 kNonStrictMode), |
10744 Handle<JSObject>()); | 10748 Handle<JSObject>()); |
10745 } | 10749 } |
10746 } | 10750 } |
10747 } | 10751 } |
10748 } | 10752 } |
10749 | 10753 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10790 Handle<FixedArray> keys = | 10794 Handle<FixedArray> keys = |
10791 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 10795 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
10792 if (threw) return Handle<JSObject>(); | 10796 if (threw) return Handle<JSObject>(); |
10793 | 10797 |
10794 for (int i = 0; i < keys->length(); i++) { | 10798 for (int i = 0; i < keys->length(); i++) { |
10795 // Names of variables introduced by eval are strings. | 10799 // Names of variables introduced by eval are strings. |
10796 ASSERT(keys->get(i)->IsString()); | 10800 ASSERT(keys->get(i)->IsString()); |
10797 Handle<String> key(String::cast(keys->get(i))); | 10801 Handle<String> key(String::cast(keys->get(i))); |
10798 RETURN_IF_EMPTY_HANDLE_VALUE( | 10802 RETURN_IF_EMPTY_HANDLE_VALUE( |
10799 isolate, | 10803 isolate, |
10800 SetProperty(closure_scope, | 10804 SetProperty(isolate, |
| 10805 closure_scope, |
10801 key, | 10806 key, |
10802 GetProperty(ext, key), | 10807 GetProperty(ext, key), |
10803 NONE, | 10808 NONE, |
10804 kNonStrictMode), | 10809 kNonStrictMode), |
10805 Handle<JSObject>()); | 10810 Handle<JSObject>()); |
10806 } | 10811 } |
10807 } | 10812 } |
10808 | 10813 |
10809 return closure_scope; | 10814 return closure_scope; |
10810 } | 10815 } |
10811 | 10816 |
10812 | 10817 |
10813 // Create a plain JSObject which materializes the scope for the specified | 10818 // Create a plain JSObject which materializes the scope for the specified |
10814 // catch context. | 10819 // catch context. |
10815 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, | 10820 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, |
10816 Handle<Context> context) { | 10821 Handle<Context> context) { |
10817 ASSERT(context->IsCatchContext()); | 10822 ASSERT(context->IsCatchContext()); |
10818 Handle<String> name(String::cast(context->extension())); | 10823 Handle<String> name(String::cast(context->extension())); |
10819 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX)); | 10824 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX)); |
10820 Handle<JSObject> catch_scope = | 10825 Handle<JSObject> catch_scope = |
10821 isolate->factory()->NewJSObject(isolate->object_function()); | 10826 isolate->factory()->NewJSObject(isolate->object_function()); |
10822 RETURN_IF_EMPTY_HANDLE_VALUE( | 10827 RETURN_IF_EMPTY_HANDLE_VALUE( |
10823 isolate, | 10828 isolate, |
10824 SetProperty(catch_scope, name, thrown_object, NONE, kNonStrictMode), | 10829 SetProperty(isolate, |
| 10830 catch_scope, |
| 10831 name, |
| 10832 thrown_object, |
| 10833 NONE, |
| 10834 kNonStrictMode), |
10825 Handle<JSObject>()); | 10835 Handle<JSObject>()); |
10826 return catch_scope; | 10836 return catch_scope; |
10827 } | 10837 } |
10828 | 10838 |
10829 | 10839 |
10830 // Create a plain JSObject which materializes the block scope for the specified | 10840 // Create a plain JSObject which materializes the block scope for the specified |
10831 // block context. | 10841 // block context. |
10832 static Handle<JSObject> MaterializeBlockScope( | 10842 static Handle<JSObject> MaterializeBlockScope( |
10833 Isolate* isolate, | 10843 Isolate* isolate, |
10834 Handle<Context> context) { | 10844 Handle<Context> context) { |
(...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13321 // Handle last resort GC and make sure to allow future allocations | 13331 // Handle last resort GC and make sure to allow future allocations |
13322 // to grow the heap without causing GCs (if possible). | 13332 // to grow the heap without causing GCs (if possible). |
13323 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13333 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13324 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13334 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13325 "Runtime::PerformGC"); | 13335 "Runtime::PerformGC"); |
13326 } | 13336 } |
13327 } | 13337 } |
13328 | 13338 |
13329 | 13339 |
13330 } } // namespace v8::internal | 13340 } } // namespace v8::internal |
OLD | NEW |