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 13768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13779 if (proto->IsNull()) return isolate->heap()->false_value(); | 13779 if (proto->IsNull()) return isolate->heap()->false_value(); |
13780 ASSERT(proto->IsJSGlobalObject()); | 13780 ASSERT(proto->IsJSGlobalObject()); |
13781 obj = JSReceiver::cast(proto); | 13781 obj = JSReceiver::cast(proto); |
13782 } | 13782 } |
13783 return isolate->heap()->ToBoolean(obj->map()->is_observed()); | 13783 return isolate->heap()->ToBoolean(obj->map()->is_observed()); |
13784 } | 13784 } |
13785 | 13785 |
13786 | 13786 |
13787 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { | 13787 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { |
13788 SealHandleScope shs(isolate); | 13788 SealHandleScope shs(isolate); |
13789 ASSERT(args.length() == 2); | 13789 ASSERT(args.length() == 1); |
13790 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 13790 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
13791 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); | |
13792 if (obj->IsJSGlobalProxy()) { | 13791 if (obj->IsJSGlobalProxy()) { |
13793 Object* proto = obj->GetPrototype(); | 13792 Object* proto = obj->GetPrototype(); |
13794 if (proto->IsNull()) return isolate->heap()->undefined_value(); | 13793 if (proto->IsNull()) return isolate->heap()->undefined_value(); |
13795 ASSERT(proto->IsJSGlobalObject()); | 13794 ASSERT(proto->IsJSGlobalObject()); |
13796 obj = JSReceiver::cast(proto); | 13795 obj = JSReceiver::cast(proto); |
13797 } | 13796 } |
13798 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && | 13797 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && |
13799 JSObject::cast(obj)->HasFastElements())); | 13798 JSObject::cast(obj)->HasFastElements())); |
13800 if (obj->map()->is_observed() != is_observed) { | 13799 ASSERT(obj->IsJSObject()); |
13801 if (is_observed && obj->IsJSObject() && | 13800 return JSObject::cast(obj)->SetObserved(isolate); |
13802 !JSObject::cast(obj)->HasExternalArrayElements()) { | |
13803 // Go to dictionary mode, so that we don't skip map checks. | |
13804 MaybeObject* maybe = JSObject::cast(obj)->NormalizeElements(); | |
13805 if (maybe->IsFailure()) return maybe; | |
13806 ASSERT(!JSObject::cast(obj)->HasFastElements()); | |
13807 } | |
13808 MaybeObject* maybe = obj->map()->Copy(); | |
13809 Map* map; | |
13810 if (!maybe->To(&map)) return maybe; | |
13811 map->set_is_observed(is_observed); | |
13812 obj->set_map(map); | |
13813 } | |
13814 return isolate->heap()->undefined_value(); | |
13815 } | 13801 } |
13816 | 13802 |
13817 | 13803 |
13818 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { | 13804 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { |
13819 SealHandleScope shs(isolate); | 13805 SealHandleScope shs(isolate); |
13820 ASSERT(args.length() == 0); | 13806 ASSERT(args.length() == 0); |
13821 isolate->set_observer_delivery_pending(true); | 13807 isolate->set_observer_delivery_pending(true); |
13822 return isolate->heap()->undefined_value(); | 13808 return isolate->heap()->undefined_value(); |
13823 } | 13809 } |
13824 | 13810 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14038 // Handle last resort GC and make sure to allow future allocations | 14024 // Handle last resort GC and make sure to allow future allocations |
14039 // to grow the heap without causing GCs (if possible). | 14025 // to grow the heap without causing GCs (if possible). |
14040 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14026 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14041 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14027 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14042 "Runtime::PerformGC"); | 14028 "Runtime::PerformGC"); |
14043 } | 14029 } |
14044 } | 14030 } |
14045 | 14031 |
14046 | 14032 |
14047 } } // namespace v8::internal | 14033 } } // namespace v8::internal |
OLD | NEW |