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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 memset(data, 0, allocated_length); | 707 memset(data, 0, allocated_length); |
708 } else { | 708 } else { |
709 data = NULL; | 709 data = NULL; |
710 } | 710 } |
711 | 711 |
712 SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length); | 712 SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length); |
713 | 713 |
714 v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 714 v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
715 v8::Persistent<v8::Value> weak_handle( | 715 v8::Persistent<v8::Value> weak_handle( |
716 external_isolate, v8::Utils::ToLocal(Handle<Object>::cast(array_buffer))); | 716 external_isolate, v8::Utils::ToLocal(Handle<Object>::cast(array_buffer))); |
717 weak_handle.MakeWeak(external_isolate, data, ArrayBufferWeakCallback); | 717 weak_handle.MakeWeak(data, ArrayBufferWeakCallback); |
718 weak_handle.MarkIndependent(external_isolate); | 718 weak_handle.MarkIndependent(external_isolate); |
719 isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length); | 719 isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length); |
720 | 720 |
721 return true; | 721 return true; |
722 } | 722 } |
723 | 723 |
724 | 724 |
725 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferInitialize) { | 725 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferInitialize) { |
726 HandleScope scope(isolate); | 726 HandleScope scope(isolate); |
727 ASSERT(args.length() == 2); | 727 ASSERT(args.length() == 2); |
(...skipping 12907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13635 // Handle last resort GC and make sure to allow future allocations | 13635 // Handle last resort GC and make sure to allow future allocations |
13636 // to grow the heap without causing GCs (if possible). | 13636 // to grow the heap without causing GCs (if possible). |
13637 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13637 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13638 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13638 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13639 "Runtime::PerformGC"); | 13639 "Runtime::PerformGC"); |
13640 } | 13640 } |
13641 } | 13641 } |
13642 | 13642 |
13643 | 13643 |
13644 } } // namespace v8::internal | 13644 } } // namespace v8::internal |
OLD | NEW |