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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 | 818 |
819 holder->set_buffer(*buffer); | 819 holder->set_buffer(*buffer); |
820 holder->set_byte_offset(*byte_offset_object); | 820 holder->set_byte_offset(*byte_offset_object); |
821 holder->set_byte_length(*byte_length_object); | 821 holder->set_byte_length(*byte_length_object); |
822 | 822 |
823 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 823 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); |
824 size_t byte_length = NumberToSize(isolate, *byte_length_object); | 824 size_t byte_length = NumberToSize(isolate, *byte_length_object); |
825 ASSERT(byte_length % elementSize == 0); | 825 ASSERT(byte_length % elementSize == 0); |
826 size_t length = byte_length / elementSize; | 826 size_t length = byte_length / elementSize; |
827 | 827 |
828 holder->set_length( | 828 Handle<Object> length_obj = isolate->factory()->NewNumber(length); |
829 *isolate->factory()->NewNumber(static_cast<double>(length))); | 829 holder->set_length(*length_obj); |
830 Handle<ExternalArray> elements = | 830 Handle<ExternalArray> elements = |
831 isolate->factory()->NewExternalArray( | 831 isolate->factory()->NewExternalArray( |
832 static_cast<int>(length), arrayType, | 832 static_cast<int>(length), arrayType, |
833 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 833 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
834 Handle<Map> map = | 834 Handle<Map> map = |
835 isolate->factory()->GetElementsTransitionMap(holder, elementsKind); | 835 isolate->factory()->GetElementsTransitionMap(holder, elementsKind); |
836 holder->set_map(*map); | 836 holder->set_map(*map); |
837 holder->set_elements(*elements); | 837 holder->set_elements(*elements); |
838 return isolate->heap()->undefined_value(); | 838 return isolate->heap()->undefined_value(); |
839 } | 839 } |
(...skipping 12366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13206 // Handle last resort GC and make sure to allow future allocations | 13206 // Handle last resort GC and make sure to allow future allocations |
13207 // to grow the heap without causing GCs (if possible). | 13207 // to grow the heap without causing GCs (if possible). |
13208 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13208 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13209 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13209 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13210 "Runtime::PerformGC"); | 13210 "Runtime::PerformGC"); |
13211 } | 13211 } |
13212 } | 13212 } |
13213 | 13213 |
13214 | 13214 |
13215 } } // namespace v8::internal | 13215 } } // namespace v8::internal |
OLD | NEW |