| 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 array_buffer->SetInternalField(i, Smi::FromInt(0)); | 680 array_buffer->SetInternalField(i, Smi::FromInt(0)); |
| 681 } | 681 } |
| 682 array_buffer->set_backing_store(data); | 682 array_buffer->set_backing_store(data); |
| 683 array_buffer->set_flag(Smi::FromInt(0)); | 683 array_buffer->set_flag(Smi::FromInt(0)); |
| 684 array_buffer->set_is_external(is_external); | 684 array_buffer->set_is_external(is_external); |
| 685 | 685 |
| 686 Handle<Object> byte_length = | 686 Handle<Object> byte_length = |
| 687 isolate->factory()->NewNumberFromSize(allocated_length); | 687 isolate->factory()->NewNumberFromSize(allocated_length); |
| 688 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); | 688 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); |
| 689 array_buffer->set_byte_length(*byte_length); | 689 array_buffer->set_byte_length(*byte_length); |
| 690 |
| 691 array_buffer->set_weak_next(isolate->heap()->array_buffers_list()); |
| 692 isolate->heap()->set_array_buffers_list(*array_buffer); |
| 693 array_buffer->set_weak_first_array(Smi::FromInt(0)); |
| 690 } | 694 } |
| 691 | 695 |
| 692 | 696 |
| 693 bool Runtime::SetupArrayBufferAllocatingData( | 697 bool Runtime::SetupArrayBufferAllocatingData( |
| 694 Isolate* isolate, | 698 Isolate* isolate, |
| 695 Handle<JSArrayBuffer> array_buffer, | 699 Handle<JSArrayBuffer> array_buffer, |
| 696 size_t allocated_length) { | 700 size_t allocated_length) { |
| 697 void* data; | 701 void* data; |
| 698 if (allocated_length != 0) { | 702 if (allocated_length != 0) { |
| 699 data = malloc(allocated_length); | 703 data = malloc(allocated_length); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 holder->set_byte_offset(*byte_offset_object); | 852 holder->set_byte_offset(*byte_offset_object); |
| 849 holder->set_byte_length(*byte_length_object); | 853 holder->set_byte_length(*byte_length_object); |
| 850 | 854 |
| 851 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 855 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); |
| 852 size_t byte_length = NumberToSize(isolate, *byte_length_object); | 856 size_t byte_length = NumberToSize(isolate, *byte_length_object); |
| 853 ASSERT(byte_length % elementSize == 0); | 857 ASSERT(byte_length % elementSize == 0); |
| 854 size_t length = byte_length / elementSize; | 858 size_t length = byte_length / elementSize; |
| 855 | 859 |
| 856 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); | 860 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); |
| 857 holder->set_length(*length_obj); | 861 holder->set_length(*length_obj); |
| 862 holder->set_weak_next(buffer->weak_first_array()); |
| 863 buffer->set_weak_first_array(*holder); |
| 858 | 864 |
| 859 Handle<ExternalArray> elements = | 865 Handle<ExternalArray> elements = |
| 860 isolate->factory()->NewExternalArray( | 866 isolate->factory()->NewExternalArray( |
| 861 static_cast<int>(length), arrayType, | 867 static_cast<int>(length), arrayType, |
| 862 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 868 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
| 863 holder->set_elements(*elements); | 869 holder->set_elements(*elements); |
| 864 return isolate->heap()->undefined_value(); | 870 return isolate->heap()->undefined_value(); |
| 865 } | 871 } |
| 866 | 872 |
| 867 | 873 |
| (...skipping 12656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13524 // Handle last resort GC and make sure to allow future allocations | 13530 // Handle last resort GC and make sure to allow future allocations |
| 13525 // to grow the heap without causing GCs (if possible). | 13531 // to grow the heap without causing GCs (if possible). |
| 13526 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13532 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13527 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13533 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13528 "Runtime::PerformGC"); | 13534 "Runtime::PerformGC"); |
| 13529 } | 13535 } |
| 13530 } | 13536 } |
| 13531 | 13537 |
| 13532 | 13538 |
| 13533 } } // namespace v8::internal | 13539 } } // namespace v8::internal |
| OLD | NEW |