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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 850 |
851 holder->set_buffer(*buffer); | 851 holder->set_buffer(*buffer); |
852 holder->set_byte_offset(*byte_offset_object); | 852 holder->set_byte_offset(*byte_offset_object); |
853 holder->set_byte_length(*byte_length_object); | 853 holder->set_byte_length(*byte_length_object); |
854 | 854 |
855 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 855 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); |
856 size_t byte_length = NumberToSize(isolate, *byte_length_object); | 856 size_t byte_length = NumberToSize(isolate, *byte_length_object); |
857 ASSERT(byte_length % elementSize == 0); | 857 ASSERT(byte_length % elementSize == 0); |
858 size_t length = byte_length / elementSize; | 858 size_t length = byte_length / elementSize; |
859 | 859 |
860 Handle<Object> length_obj = | 860 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); |
861 isolate->factory()->NewNumber(static_cast<double>(length)); | |
862 holder->set_length(*length_obj); | 861 holder->set_length(*length_obj); |
| 862 |
863 Handle<ExternalArray> elements = | 863 Handle<ExternalArray> elements = |
864 isolate->factory()->NewExternalArray( | 864 isolate->factory()->NewExternalArray( |
865 static_cast<int>(length), arrayType, | 865 static_cast<int>(length), arrayType, |
866 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 866 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
867 Handle<Map> map = | 867 Handle<Map> map = |
868 isolate->factory()->GetElementsTransitionMap(holder, elementsKind); | 868 isolate->factory()->GetElementsTransitionMap(holder, elementsKind); |
869 holder->set_map(*map); | 869 holder->set_map(*map); |
870 holder->set_elements(*elements); | 870 holder->set_elements(*elements); |
871 return isolate->heap()->undefined_value(); | 871 return isolate->heap()->undefined_value(); |
872 } | 872 } |
(...skipping 12634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13507 // Handle last resort GC and make sure to allow future allocations | 13507 // Handle last resort GC and make sure to allow future allocations |
13508 // to grow the heap without causing GCs (if possible). | 13508 // to grow the heap without causing GCs (if possible). |
13509 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13509 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13510 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13510 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13511 "Runtime::PerformGC"); | 13511 "Runtime::PerformGC"); |
13512 } | 13512 } |
13513 } | 13513 } |
13514 | 13514 |
13515 | 13515 |
13516 } } // namespace v8::internal | 13516 } } // namespace v8::internal |
OLD | NEW |