Chromium Code Reviews| 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 if (Smi::IsValid(static_cast<intptr_t>(length))) { |
|
rossberg
2013/05/14 14:00:45
I think this should be refactored into a function
| |
| 861 isolate->factory()->NewNumber(static_cast<double>(length)); | 861 holder->set_length(Smi::FromIntptr(length)); |
| 862 holder->set_length(*length_obj); | 862 } else { |
| 863 Handle<Object> length_obj= | |
| 864 isolate->factory()->NewNumber(static_cast<double>(length)); | |
| 865 holder->set_length(*length_obj); | |
| 866 } | |
| 867 | |
| 863 Handle<ExternalArray> elements = | 868 Handle<ExternalArray> elements = |
| 864 isolate->factory()->NewExternalArray( | 869 isolate->factory()->NewExternalArray( |
| 865 static_cast<int>(length), arrayType, | 870 static_cast<int>(length), arrayType, |
| 866 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 871 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
| 867 Handle<Map> map = | 872 Handle<Map> map = |
| 868 isolate->factory()->GetElementsTransitionMap(holder, elementsKind); | 873 isolate->factory()->GetElementsTransitionMap(holder, elementsKind); |
| 869 holder->set_map(*map); | 874 holder->set_map(*map); |
| 870 holder->set_elements(*elements); | 875 holder->set_elements(*elements); |
| 871 return isolate->heap()->undefined_value(); | 876 return isolate->heap()->undefined_value(); |
| 872 } | 877 } |
| (...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 | 13512 // Handle last resort GC and make sure to allow future allocations |
| 13508 // to grow the heap without causing GCs (if possible). | 13513 // to grow the heap without causing GCs (if possible). |
| 13509 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13514 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13510 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13515 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13511 "Runtime::PerformGC"); | 13516 "Runtime::PerformGC"); |
| 13512 } | 13517 } |
| 13513 } | 13518 } |
| 13514 | 13519 |
| 13515 | 13520 |
| 13516 } } // namespace v8::internal | 13521 } } // namespace v8::internal |
| OLD | NEW |