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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 | 844 |
845 memset(data, 0, allocated_length); | 845 memset(data, 0, allocated_length); |
846 } else { | 846 } else { |
847 data = NULL; | 847 data = NULL; |
848 } | 848 } |
849 holder->set_backing_store(data); | 849 holder->set_backing_store(data); |
850 | 850 |
851 Object* byte_length; | 851 Object* byte_length; |
852 { | 852 { |
853 MaybeObject* maybe_byte_length = | 853 MaybeObject* maybe_byte_length = |
854 isolate->heap()->NumberFromDouble(allocated_length); | 854 isolate->heap()->NumberFromDouble( |
| 855 static_cast<double>(allocated_length)); |
855 if (!maybe_byte_length->ToObject(&byte_length)) return maybe_byte_length; | 856 if (!maybe_byte_length->ToObject(&byte_length)) return maybe_byte_length; |
856 } | 857 } |
857 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); | 858 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); |
858 holder->set_byte_length(byte_length); | 859 holder->set_byte_length(byte_length); |
859 | 860 |
860 v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 861 v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
861 v8::Handle<Object> external_holder(*holder); | 862 v8::Handle<Object> external_holder(*holder); |
862 Persistent<Object> weak_handle = Persistent<Object>::New( | 863 Persistent<Object> weak_handle = Persistent<Object>::New( |
863 external_isolate, external_holder); | 864 external_isolate, external_holder); |
864 weak_handle.MakeWeak(external_isolate, data, ArrayBufferWeakCallback); | 865 weak_handle.MakeWeak(external_isolate, data, ArrayBufferWeakCallback); |
(...skipping 12285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13150 // Handle last resort GC and make sure to allow future allocations | 13151 // Handle last resort GC and make sure to allow future allocations |
13151 // to grow the heap without causing GCs (if possible). | 13152 // to grow the heap without causing GCs (if possible). |
13152 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13153 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13153 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13154 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13154 "Runtime::PerformGC"); | 13155 "Runtime::PerformGC"); |
13155 } | 13156 } |
13156 } | 13157 } |
13157 | 13158 |
13158 | 13159 |
13159 } } // namespace v8::internal | 13160 } } // namespace v8::internal |
OLD | NEW |